



"""simple docstring"""





from collections import OrderedDict
from typing import Mapping

from packaging import version

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


lowercase  							=					logging.get_logger(__name__)

lowercase  							=					{
    '''microsoft/resnet-50''': '''https://huggingface.co/microsoft/resnet-50/blob/main/config.json''',
}




class 			lowercase__			(      A,					A    ):
							'''simple docstring'''







							_UpperCAmelCase      				=					'''resnet'''
							_UpperCAmelCase      				=					['''basic''', '''bottleneck''']






							def __init__(  self	,       snake_case=3	,       snake_case=64	,       snake_case=[256, 512, 1024, 2048]	,       snake_case=[3, 4, 6, 3]	,       snake_case="bottleneck"	,       snake_case="relu"	,       snake_case=False	,       snake_case=None	,       snake_case=None	,       **snake_case	,       )			->							Optional[int]:
									super().__init__(**snake_case						)
									if layer_type not in self.layer_types:
											raise ValueError(f'layer_type={layer_type} is not one of {",".join(self.layer_types						)}'						)
									_UpperCAmelCase							 =		num_channels
									_UpperCAmelCase							 =		embedding_size
									_UpperCAmelCase							 =		hidden_sizes
									_UpperCAmelCase							 =		depths
									_UpperCAmelCase							 =		layer_type
									_UpperCAmelCase							 =		hidden_act
									_UpperCAmelCase							 =		downsample_in_first_stage
									_UpperCAmelCase							 =		['stem'] + [f'stage{idx}' for idx in range(1	,       len(snake_case						) + 1						)]
									_UpperCAmelCase ,					_UpperCAmelCase							 =		get_aligned_output_features_output_indices(
									    out_features=snake_case	,       out_indices=snake_case	,       stage_names=self.stage_names						)







class 			lowercase__			(      A    ):
							'''simple docstring'''







							_UpperCAmelCase      				=					version.parse('''1.11'''    )






							@property
							def        lowerCamelCase_   (  self						)			->							Mapping[str, Mapping[int, str]]:
									return OrderedDict(
									    [
									        ('pixel_values', {0: 'batch', 1: 'num_channels', 2: 'height', 3: 'width'}),
									    ]						)






							@property
							def        lowerCamelCase_   (  self						)			->							float:
									return 1E-3







"""simple docstring"""





def 	UpperCAmelCase     (		A	:						int       ):

		'''simple docstring'''


		_UpperCAmelCase							 =		abs(A       )
		_UpperCAmelCase							 =		0
		while n > 0:
				res += n % 10
				n //= 10
		return res




def 	UpperCAmelCase     (		A	:						int       ):

		'''simple docstring'''


		_UpperCAmelCase							 =		abs(A       )
		return n if n < 10 else n % 10 + sum_of_digits(n // 10       )




def 	UpperCAmelCase     (		A	:						int       ):

		'''simple docstring'''


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




def 	UpperCAmelCase     (		):

		'''simple docstring'''


		from collections.abc import Callable
		from timeit import timeit

		def benchmark_a_function(A	:						Callable     ,				A	:						int       ) -> None:
				_UpperCAmelCase							 =		f'{func.__name__}({value})'
				_UpperCAmelCase							 =		timeit(f'__main__.{call}'     ,				setup='import __main__'       )
				print(f'{call:56} = {func(A       )} -- {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(A     ,				A       )
				print()


if __name__ == "__main__":
					import doctest

					doctest.testmod()
					benchmark()


