
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


__lowerCamelCase							=       logging.get_logger(__name__)

__lowerCamelCase							=       {
    """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   UpperCAmelCase		(						A_       ,A_ ):
   A__					:		Optional[Any]						     =     "swin"

   A__					:		str						     =     {
       "num_attention_heads": "num_heads",
       "num_hidden_layers": "num_layers",
   }



   def __init__(self		:					Optional[Any]    ,						snake_case__		:					Optional[Any]=2_24    ,						snake_case__		:					List[str]=4    ,						snake_case__		:					Union[str, Any]=3    ,						snake_case__		:					Tuple=96    ,						snake_case__		:					List[Any]=[2, 2, 6, 2]    ,						snake_case__		:					Dict=[3, 6, 12, 24]    ,						snake_case__		:					Optional[Any]=7    ,						snake_case__		:					int=4.0    ,						snake_case__		:					Tuple=True    ,						snake_case__		:					List[str]=0.0    ,						snake_case__		:					Optional[int]=0.0    ,						snake_case__		:					Tuple=0.1    ,						snake_case__		:					Dict="gelu"    ,						snake_case__		:					int=False    ,						snake_case__		:					Dict=0.02    ,						snake_case__		:					List[str]=1e-5    ,						snake_case__		:					Union[str, Any]=32    ,						snake_case__		:					Any=None    ,						snake_case__		:					Tuple=None    ,						**snake_case__		:					List[str]    ,						)		->	Tuple:


          '''simple docstring'''


          super().__init__(**snake_case__ )

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






class   UpperCAmelCase		(						A_ ):
   A__					:		Dict						     =     version.parse("1.11" )



   @property
   def 				_SCREAMING_SNAKE_CASE   (self		:					Any )		->	Mapping[str, Mapping[int, str]]:


          '''simple docstring'''


          return OrderedDict(
              [
                  ("pixel_values", {0: "batch", 1: "num_channels", 2: "height", 3: "width"}),
              ] )



   @property
   def 				_SCREAMING_SNAKE_CASE   (self		:					int )		->	float:


          '''simple docstring'''


          return 1e-4







from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_flax_available,
    is_sentencepiece_available,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


__lowerCamelCase							=       {"""configuration_xglm""": ["""XGLM_PRETRAINED_CONFIG_ARCHIVE_MAP""", """XGLMConfig"""]}

try:
   if not is_sentencepiece_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   __lowerCamelCase							=       ["""XGLMTokenizer"""]

try:
   if not is_tokenizers_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   __lowerCamelCase							=       ["""XGLMTokenizerFast"""]

try:
   if not is_torch_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   __lowerCamelCase							=       [
       """XGLM_PRETRAINED_MODEL_ARCHIVE_LIST""",
       """XGLMForCausalLM""",
       """XGLMModel""",
       """XGLMPreTrainedModel""",
   ]


try:
   if not is_flax_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   __lowerCamelCase							=       [
       """FlaxXGLMForCausalLM""",
       """FlaxXGLMModel""",
       """FlaxXGLMPreTrainedModel""",
   ]


try:
   if not is_tf_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   __lowerCamelCase							=       [
       """TF_XGLM_PRETRAINED_MODEL_ARCHIVE_LIST""",
       """TFXGLMForCausalLM""",
       """TFXGLMModel""",
       """TFXGLMPreTrainedModel""",
   ]


if TYPE_CHECKING:
   from .configuration_xglm import XGLM_PRETRAINED_CONFIG_ARCHIVE_MAP, XGLMConfig

   try:
      if not is_sentencepiece_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .tokenization_xglm import XGLMTokenizer

   try:
      if not is_tokenizers_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .tokenization_xglm_fast import XGLMTokenizerFast

   try:
      if not is_torch_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_xglm import XGLM_PRETRAINED_MODEL_ARCHIVE_LIST, XGLMForCausalLM, XGLMModel, XGLMPreTrainedModel

   try:
      if not is_flax_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_flax_xglm import FlaxXGLMForCausalLM, FlaxXGLMModel, FlaxXGLMPreTrainedModel

   try:
      if not is_tf_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_tf_xglm import (
          TF_XGLM_PRETRAINED_MODEL_ARCHIVE_LIST,
          TFXGLMForCausalLM,
          TFXGLMModel,
          TFXGLMPreTrainedModel,
      )


else:
   import sys

   __lowerCamelCase							=       _LazyModule(__name__, globals()["""__file__"""], _import_structure)





