


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


snake_case				:    Optional[int]       				=     logging.get_logger(__name__)

snake_case				:    Any       				=     {
    '''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 		_snake_case  (      _snake_case						,    _snake_case							):
 SCREAMING_SNAKE_CASE__      =       'swin'

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




 def __init__(		self					,  _lowerCamelCase=224					,  _lowerCamelCase=4					,  _lowerCamelCase=3					,  _lowerCamelCase=96					,  _lowerCamelCase=[2, 2, 6, 2]					,  _lowerCamelCase=[3, 6, 12, 24]					,  _lowerCamelCase=7					,  _lowerCamelCase=4.0					,  _lowerCamelCase=True					,  _lowerCamelCase=0.0					,  _lowerCamelCase=0.0					,  _lowerCamelCase=0.1					,  _lowerCamelCase="gelu"					,  _lowerCamelCase=False					,  _lowerCamelCase=0.02					,  _lowerCamelCase=1e-5					,  _lowerCamelCase=32					,  _lowerCamelCase=None					,  _lowerCamelCase=None					,  **_lowerCamelCase					,  ):
       super().__init__(**_lowerCamelCase    )

       a						:Optional[Any] 							=       image_size
       a						:List[Any] 							=       patch_size
       a						:Any 							=       num_channels
       a						:str 							=       embed_dim
       a						:str 							=       depths
       a						:Optional[Any] 							=       len(_lowerCamelCase    )
       a						:int 							=       num_heads
       a						:str 							=       window_size
       a						:List[Any] 							=       mlp_ratio
       a						:Union[str, Any] 							=       qkv_bias
       a						:Optional[Any] 							=       hidden_dropout_prob
       a						:List[Any] 							=       attention_probs_dropout_prob
       a						:Any 							=       drop_path_rate
       a						:Dict 							=       hidden_act
       a						:Union[str, Any] 							=       use_absolute_embeddings
       a						:Tuple 							=       layer_norm_eps
       a						:Optional[Any] 							=       initializer_range
       a						:List[str] 							=       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						:List[str] 							=       int(embed_dim * 2 ** (len(_lowerCamelCase    ) - 1)    )
       a						:List[Any] 							=       ['''stem'''] + [F'''stage{idx}''' for idx in range(1					,  len(_lowerCamelCase    ) + 1    )]
       a							,				a						:Dict 							=       get_aligned_output_features_output_indices(
           out_features=_lowerCamelCase					,  out_indices=_lowerCamelCase					,  stage_names=self.stage_names    )







class 		_snake_case  (      _snake_case							):
 SCREAMING_SNAKE_CASE__      =       version.parse('1.11'							)




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




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









import sys

from .dependency_versions_table import deps
from .utils.versions import require_version, require_version_core


# define which module versions we always want to check at run time
# (usually the ones defined in `install_requires` in setup.py)
#
# order specific notes:
# - tqdm must be checked before tokenizers

snake_case				:    Union[str, Any]       				=     '''python tqdm regex requests packaging filelock numpy tokenizers'''.split()
if sys.version_info < (3, 7):
     pkgs_to_check_at_runtime.append('''dataclasses''')
if sys.version_info < (3, 8):
     pkgs_to_check_at_runtime.append('''importlib_metadata''')

for pkg in pkgs_to_check_at_runtime:
     if pkg in deps:
          if pkg == "tokenizers":
               # must be loaded here, or else tqdm check may fail
               from .utils import is_tokenizers_available

               if not is_tokenizers_available():
                    continue  # not required, check version only if installed

          require_version_core(deps[pkg])
     else:
          raise ValueError(F"""can't find {pkg} in {deps.keys()}, check dependency_versions_table.py""")
def 				__lowerCamelCase						( UpperCAmelCase_						:		Any ,  UpperCAmelCase_						:		Optional[int]=None						):




      """simple docstring"""





      require_version(deps[pkg] ,  UpperCAmelCase_						)





