




'''simple docstring'''

def 		__magic_name__    (	__UpperCAmelCase	)		->					int:

					'''simple docstring'''

					snake_case_									=				abs(__UpperCAmelCase	)
					snake_case_									=				0
					while n > 0:
										res += n % 10
										n //= 10
					return res


def 		__magic_name__    (	__UpperCAmelCase	)		->					int:

					'''simple docstring'''

					snake_case_									=				abs(__UpperCAmelCase	)
					return n if n < 10 else n % 10 + sum_of_digits(n // 10	)


def 		__magic_name__    (	__UpperCAmelCase	)		->					int:

					'''simple docstring'''

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


def 		__magic_name__    (	)		->					None:

					'''simple docstring'''

					from collections.abc import Callable
					from timeit import timeit

					def benchmark_a_function(__UpperCAmelCase,      __UpperCAmelCase	) -> None:
										snake_case_									=				F"{func.__name__}({value})"
										snake_case_									=				timeit(F"__main__.{call}",      setup='''import __main__'''	)
										print(F"{call:56} = {func(__UpperCAmelCase	)} -- {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(__UpperCAmelCase,      __UpperCAmelCase	)
										print()


if __name__ == "__main__":
							import doctest

							doctest.testmod()
							benchmark()






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


A__  :  List[str]								=					logging.get_logger(__name__)



class 				__snake_case						(     UpperCamelCase_						,UpperCamelCase_						):
							_a			      = '''maskformer-swin'''

							_a			      = {
							    '''num_attention_heads''': '''num_heads''',
							    '''num_hidden_layers''': '''num_layers''',
							}




							def __init__(       self     :       Union[str, Any]				,				A_     :       Dict=2_2_4				,				A_     :       Optional[Any]=4				,				A_     :       List[str]=3				,				A_     :       str=9_6				,				A_     :       Optional[Any]=[2, 2, 6, 2]				,				A_     :       Tuple=[3, 6, 1_2, 2_4]				,				A_     :       List[Any]=7				,				A_     :       List[Any]=4.0				,				A_     :       List[str]=True				,				A_     :       Dict=0.0				,				A_     :       int=0.0				,				A_     :       str=0.1				,				A_     :       Optional[int]="gelu"				,				A_     :       List[Any]=False				,				A_     :       int=0.02				,				A_     :       int=1e-5				,				A_     :       Optional[int]=None				,				A_     :       List[str]=None				,				**A_     :       List[Any]				,				):
									super().__init__(**A_)

									lowerCAmelCase_			:     Dict									= image_size
									lowerCAmelCase_			:     Optional[Any]									= patch_size
									lowerCAmelCase_			:     Tuple									= num_channels
									lowerCAmelCase_			:     Any									= embed_dim
									lowerCAmelCase_			:     List[str]									= depths
									lowerCAmelCase_			:     Union[str, Any]									= len(A_)
									lowerCAmelCase_			:     List[str]									= num_heads
									lowerCAmelCase_			:     Dict									= window_size
									lowerCAmelCase_			:     Optional[int]									= mlp_ratio
									lowerCAmelCase_			:     Dict									= qkv_bias
									lowerCAmelCase_			:     str									= hidden_dropout_prob
									lowerCAmelCase_			:     List[str]									= attention_probs_dropout_prob
									lowerCAmelCase_			:     Optional[int]									= drop_path_rate
									lowerCAmelCase_			:     Any									= hidden_act
									lowerCAmelCase_			:     str									= use_absolute_embeddings
									lowerCAmelCase_			:     List[str]									= layer_norm_eps
									lowerCAmelCase_			:     int									= initializer_range
									# we set the hidden_size attribute in order to make Swin work with VisionEncoderDecoderModel
									# this indicates the channel dimension after the last stage of the model
									lowerCAmelCase_			:     str									= int(embed_dim * 2 ** (len(A_) - 1))
									lowerCAmelCase_			:     Optional[Any]									= ['''stem'''] + [F"""stage{idx}""" for idx in range(1				,				len(A_) + 1)]
									lowerCAmelCase_					,  lowerCAmelCase_			:     int									= get_aligned_output_features_output_indices(
									    out_features=A_				,				out_indices=A_				,				stage_names=self.stage_names)





