






from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices


A							:					Optional[Any]     						=     logging.get_logger(__name__)

A							:					str     						=     {
    '''shi-labs/nat-mini-in1k-224''': '''https://huggingface.co/shi-labs/nat-mini-in1k-224/resolve/main/config.json''',
    # See all Nat models at https://huggingface.co/models?filter=nat
}






class     UpperCamelCase(  __a     ,							__a   ):
					snake_case_		:				Any										=	'''nat'''

					snake_case_		:				List[str]										=	{
					    '''num_attention_heads''': '''num_heads''',
					    '''num_hidden_layers''': '''num_layers''',
					}


					def __init__(						self	:		Union[str, Any]     ,    SCREAMING_SNAKE_CASE	:		Optional[int]=4     ,    SCREAMING_SNAKE_CASE	:		Optional[Any]=3     ,    SCREAMING_SNAKE_CASE	:		str=6_4     ,    SCREAMING_SNAKE_CASE	:		Optional[Any]=[3, 4, 6, 5]     ,    SCREAMING_SNAKE_CASE	:		List[Any]=[2, 4, 8, 1_6]     ,    SCREAMING_SNAKE_CASE	:		Union[str, Any]=7     ,    SCREAMING_SNAKE_CASE	:		Optional[Any]=3.0     ,    SCREAMING_SNAKE_CASE	:		Tuple=True     ,    SCREAMING_SNAKE_CASE	:		Tuple=0.0     ,    SCREAMING_SNAKE_CASE	:		int=0.0     ,    SCREAMING_SNAKE_CASE	:		Any=0.1     ,    SCREAMING_SNAKE_CASE	:		List[str]="gelu"     ,    SCREAMING_SNAKE_CASE	:		Optional[Any]=0.02     ,    SCREAMING_SNAKE_CASE	:		int=1e-5     ,    SCREAMING_SNAKE_CASE	:		List[str]=0.0     ,    SCREAMING_SNAKE_CASE	:		Tuple=None     ,    SCREAMING_SNAKE_CASE	:		str=None     ,    **SCREAMING_SNAKE_CASE	:		Optional[Any]     ,    )			->	Dict:




											'''simple docstring'''

											super().__init__(**snake_case__						)

											__snake_case				=		patch_size
											__snake_case				=		num_channels
											__snake_case				=		embed_dim
											__snake_case				=		depths
											__snake_case				=		len(snake_case__						)
											__snake_case				=		num_heads
											__snake_case				=		kernel_size
											__snake_case				=		mlp_ratio
											__snake_case				=		qkv_bias
											__snake_case				=		hidden_dropout_prob
											__snake_case				=		attention_probs_dropout_prob
											__snake_case				=		drop_path_rate
											__snake_case				=		hidden_act
											__snake_case				=		layer_norm_eps
											__snake_case				=		initializer_range
											# we set the hidden_size attribute in order to make Nat work with VisionEncoderDecoderModel
											# this indicates the channel dimension after the last stage of the model
											__snake_case				=		int(embed_dim * 2 ** (len(snake_case__						) - 1)						)
											__snake_case				=		layer_scale_init_value
											__snake_case				=		["stem"] + [f'''stage{idx}''' for idx in range(1     ,    len(snake_case__						) + 1						)]
											__snake_case		,					__snake_case				=		get_aligned_output_features_output_indices(
											    out_features=snake_case__     ,    out_indices=snake_case__     ,    stage_names=self.stage_names						)









def 	_lowerCAmelCase       (    _lowerCAmelCase )						->	int:


						'''simple docstring'''






						__snake_case				=		abs(_lowerCAmelCase )
						__snake_case				=		0
						while n > 0:
												res += n % 10
												n //= 10
						return res





def 	_lowerCAmelCase       (    _lowerCAmelCase )						->	int:


						'''simple docstring'''






						__snake_case				=		abs(_lowerCAmelCase )
						return n if n < 10 else n % 10 + sum_of_digits(n // 10 )





def 	_lowerCAmelCase       (    _lowerCAmelCase )						->	int:


						'''simple docstring'''






						return sum(int(_lowerCAmelCase ) for c in str(abs(_lowerCAmelCase ) ) )





def 	_lowerCAmelCase       (    )						->	None:


						'''simple docstring'''






						from collections.abc import Callable
						from timeit import timeit

						def benchmark_a_function(_lowerCAmelCase      ,	_lowerCAmelCase ) -> None:
												__snake_case				=		F'''{func.__name__}({value})'''
												__snake_case				=		timeit(F'''__main__.{call}'''      ,	setup="import __main__" )
												print(F'''{call:56} = {func(_lowerCAmelCase )} -- {timing:.4f} seconds''' )

						for value in (26_2144, 1125_8999_0684_2624, 126_7650_6002_2822_9401_4967_0320_5376):
												for func in (sum_of_digits, sum_of_digits_recursion, sum_of_digits_compact):
																		benchmark_a_function(_lowerCAmelCase      ,	_lowerCAmelCase )
												print()


if __name__ == "__main__":
	import doctest

	doctest.testmod()
	benchmark()





