


"""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


UpperCamelCase    :					Union[str, Any]							   =   logging.get_logger(__name__)

UpperCamelCase    :					int							   =   {
    "microsoft/swin-tiny-patch4-window7-224": (
        "https://huggingface.co/microsoft/swin-tiny-patch4-window7-224/resolve/main/config.json"
    ),
    # See all Swin models at https://huggingface.co/models?filter=swin
}



class       lowerCamelCase__    ( lowerCAmelCase__				,     lowerCAmelCase__      ):
						lowerCAmelCase  	=  '''swin'''

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







						def __init__(				self :     Union[str, Any]      ,      _lowercase :     Tuple=224      ,      _lowercase :     int=4      ,      _lowercase :     List[Any]=3      ,      _lowercase :     Union[str, Any]=96      ,      _lowercase :     Tuple=[2, 2, 6, 2]      ,      _lowercase :     Optional[int]=[3, 6, 12, 24]      ,      _lowercase :     List[Any]=7      ,      _lowercase :     Union[str, Any]=4.0      ,      _lowercase :     str=True      ,      _lowercase :     List[Any]=0.0      ,      _lowercase :     Any=0.0      ,      _lowercase :     Optional[Any]=0.1      ,      _lowercase :     Tuple="gelu"      ,      _lowercase :     Union[str, Any]=False      ,      _lowercase :     Optional[int]=0.0_2      ,      _lowercase :     int=1e-5      ,      _lowercase :     Union[str, Any]=32      ,      _lowercase :     List[str]=None      ,      _lowercase :     Optional[Any]=None      ,      **_lowercase :     str      ,      ):
								super().__init__(**__lowerCAmelCase		)

								A       							=			image_size
								A       							=			patch_size
								A       							=			num_channels
								A       							=			embed_dim
								A       							=			depths
								A       							=			len(__lowerCAmelCase		)
								A       							=			num_heads
								A       							=			window_size
								A       							=			mlp_ratio
								A       							=			qkv_bias
								A       							=			hidden_dropout_prob
								A       							=			attention_probs_dropout_prob
								A       							=			drop_path_rate
								A       							=			hidden_act
								A       							=			use_absolute_embeddings
								A       							=			layer_norm_eps
								A       							=			initializer_range
								A       							=			encoder_stride
								# 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
								A       							=			int(embed_dim * 2 ** (len(__lowerCAmelCase		) - 1)		)
								A       							=			['stem'] + [f'stage{idx}' for idx in range(1      ,      len(__lowerCAmelCase		) + 1		)]
								A							,			A       							=			get_aligned_output_features_output_indices(
								    out_features=__lowerCAmelCase      ,      out_indices=__lowerCAmelCase      ,      stage_names=self.stage_names		)



class       lowerCamelCase__    ( lowerCAmelCase__      ):
						lowerCAmelCase  	=  version.parse("""1.11"""      )







						@property
						def __a    (				self :     Union[str, Any]		):
								return OrderedDict(
								    [
								        ('pixel_values', {0: 'batch', 1: 'num_channels', 2: 'height', 3: 'width'}),
								    ]		)







						@property
						def __a    (				self :     Tuple		):
								return 1e-4






'''simple docstring'''




from functools import lru_cache






@lru_cache
def 							snake_case__				(     _A:   int					)       ->      int:

		'''simple docstring'''


		if num < 0:
				raise ValueError("""Number should not be negative."""					)

		return 1 if num in (0, 1) else num * factorial(num - 1					)


if __name__ == "__main__":
						import doctest

						doctest.testmod()




