

from collections import OrderedDict
from typing import Mapping

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


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

UpperCAmelCase__ :     Any				    =    {
    """xlm-mlm-en-2048""": """https://huggingface.co/xlm-mlm-en-2048/resolve/main/config.json""",
    """xlm-mlm-ende-1024""": """https://huggingface.co/xlm-mlm-ende-1024/resolve/main/config.json""",
    """xlm-mlm-enfr-1024""": """https://huggingface.co/xlm-mlm-enfr-1024/resolve/main/config.json""",
    """xlm-mlm-enro-1024""": """https://huggingface.co/xlm-mlm-enro-1024/resolve/main/config.json""",
    """xlm-mlm-tlm-xnli15-1024""": """https://huggingface.co/xlm-mlm-tlm-xnli15-1024/resolve/main/config.json""",
    """xlm-mlm-xnli15-1024""": """https://huggingface.co/xlm-mlm-xnli15-1024/resolve/main/config.json""",
    """xlm-clm-enfr-1024""": """https://huggingface.co/xlm-clm-enfr-1024/resolve/main/config.json""",
    """xlm-clm-ende-1024""": """https://huggingface.co/xlm-clm-ende-1024/resolve/main/config.json""",
    """xlm-mlm-17-1280""": """https://huggingface.co/xlm-mlm-17-1280/resolve/main/config.json""",
    """xlm-mlm-100-1280""": """https://huggingface.co/xlm-mlm-100-1280/resolve/main/config.json""",
}







class        a__       (   UpperCAmelCase       ):







  """simple docstring"""




  UpperCAmelCase__      : Any			       ="""xlm"""
  UpperCAmelCase__      : Optional[Any]			       ={
      """hidden_size""": """emb_dim""",
      """num_attention_heads""": """n_heads""",
      """num_hidden_layers""": """n_layers""",
      """n_words""": """vocab_size""",  # For backward compatibility
  }


  def __init__(			self    : Optional[Any]				,				UpperCAmelCase__    : Union[str, Any]=3_0_1_4_5				,				UpperCAmelCase__    : Optional[int]=2_0_4_8				,				UpperCAmelCase__    : Union[str, Any]=1_2				,				UpperCAmelCase__    : Tuple=1_6				,				UpperCAmelCase__    : str=0.1				,				UpperCAmelCase__    : Optional[int]=0.1				,				UpperCAmelCase__    : Optional[Any]=True				,				UpperCAmelCase__    : Union[str, Any]=False				,				UpperCAmelCase__    : int=False				,				UpperCAmelCase__    : Any=False				,				UpperCAmelCase__    : str=1				,				UpperCAmelCase__    : Tuple=True				,				UpperCAmelCase__    : Optional[int]=5_1_2				,				UpperCAmelCase__    : List[Any]=2_0_4_8**-0.5				,				UpperCAmelCase__    : Tuple=1e-12				,				UpperCAmelCase__    : Optional[Any]=0.02				,				UpperCAmelCase__    : str=0				,				UpperCAmelCase__    : Tuple=1				,				UpperCAmelCase__    : Optional[Any]=2				,				UpperCAmelCase__    : List[str]=3				,				UpperCAmelCase__    : Optional[int]=5				,				UpperCAmelCase__    : Any=True				,				UpperCAmelCase__    : Union[str, Any]="first"				,				UpperCAmelCase__    : Optional[Any]=True				,				UpperCAmelCase__    : Optional[Any]=None				,				UpperCAmelCase__    : Union[str, Any]=True				,				UpperCAmelCase__    : int=0.1				,				UpperCAmelCase__    : int=5				,				UpperCAmelCase__    : int=5				,				UpperCAmelCase__    : Tuple=0				,				UpperCAmelCase__    : List[str]=0				,				UpperCAmelCase__    : Union[str, Any]=2				,				UpperCAmelCase__    : Union[str, Any]=0				,				**UpperCAmelCase__    : Tuple				,				)					->str:
        """simple docstring"""







        SCREAMING_SNAKE_CASE :      List[str]       =   vocab_size
        SCREAMING_SNAKE_CASE :      Tuple       =   emb_dim
        SCREAMING_SNAKE_CASE :      Optional[int]       =   n_layers
        SCREAMING_SNAKE_CASE :      Any       =   n_heads
        SCREAMING_SNAKE_CASE :      Union[str, Any]       =   dropout
        SCREAMING_SNAKE_CASE :      Optional[int]       =   attention_dropout
        SCREAMING_SNAKE_CASE :      str       =   gelu_activation
        SCREAMING_SNAKE_CASE :      Optional[Any]       =   sinusoidal_embeddings
        SCREAMING_SNAKE_CASE :      int       =   causal
        SCREAMING_SNAKE_CASE :      Tuple       =   asm
        SCREAMING_SNAKE_CASE :      Optional[int]       =   n_langs
        SCREAMING_SNAKE_CASE :      Optional[Any]       =   use_lang_emb
        SCREAMING_SNAKE_CASE :      List[str]       =   layer_norm_eps
        SCREAMING_SNAKE_CASE :      List[Any]       =   bos_index
        SCREAMING_SNAKE_CASE :      Any       =   eos_index
        SCREAMING_SNAKE_CASE :      Tuple       =   pad_index
        SCREAMING_SNAKE_CASE :      str       =   unk_index
        SCREAMING_SNAKE_CASE :      int       =   mask_index
        SCREAMING_SNAKE_CASE :      Tuple       =   is_encoder
        SCREAMING_SNAKE_CASE :      int       =   max_position_embeddings
        SCREAMING_SNAKE_CASE :      Dict       =   embed_init_std
        SCREAMING_SNAKE_CASE :      Optional[Any]       =   init_std
        SCREAMING_SNAKE_CASE :      List[str]       =   summary_type
        SCREAMING_SNAKE_CASE :      str       =   summary_use_proj
        SCREAMING_SNAKE_CASE :      int       =   summary_activation
        SCREAMING_SNAKE_CASE :      Union[str, Any]       =   summary_proj_to_labels
        SCREAMING_SNAKE_CASE :      Optional[Any]       =   summary_first_dropout
        SCREAMING_SNAKE_CASE :      Dict       =   start_n_top
        SCREAMING_SNAKE_CASE :      Any       =   end_n_top
        SCREAMING_SNAKE_CASE :      Any       =   mask_token_id
        SCREAMING_SNAKE_CASE :      Optional[Any]       =   lang_id

        if "n_words" in kwargs:
              SCREAMING_SNAKE_CASE :      Union[str, Any]       =   kwargs["""n_words"""]

        super().__init__(pad_token_id=UpperCAmelCase__				,				bos_token_id=UpperCAmelCase__				,				**UpperCAmelCase__		)







class        a__       (   UpperCAmelCase       ):







  """simple docstring"""




  @property
  def  _lowercase      (			self    : Optional[int]		)					->Mapping[str, Mapping[int, str]]:
        """simple docstring"""







        if self.task == "multiple-choice":
              SCREAMING_SNAKE_CASE :      str       =   {0: """batch""", 1: """choice""", 2: """sequence"""}
        else:
              SCREAMING_SNAKE_CASE :      str       =   {0: """batch""", 1: """sequence"""}
        return OrderedDict(
            [
                ("""input_ids""", dynamic_axis),
                ("""attention_mask""", dynamic_axis),
                ("""token_type_ids""", dynamic_axis),
            ]		)







from typing import TYPE_CHECKING

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


UpperCAmelCase__ :     List[Any]				    =    {"""configuration_vit""": ["""VIT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """ViTConfig""", """ViTOnnxConfig"""]}

try:
  if not is_vision_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  UpperCAmelCase__ :     Union[str, Any]				    =    ["""ViTFeatureExtractor"""]
  UpperCAmelCase__ :     List[Any]				    =    ["""ViTImageProcessor"""]

try:
  if not is_torch_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  UpperCAmelCase__ :     List[Any]				    =    [
      """VIT_PRETRAINED_MODEL_ARCHIVE_LIST""",
      """ViTForImageClassification""",
      """ViTForMaskedImageModeling""",
      """ViTModel""",
      """ViTPreTrainedModel""",
  ]

try:
  if not is_tf_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  UpperCAmelCase__ :     Tuple				    =    [
      """TFViTForImageClassification""",
      """TFViTModel""",
      """TFViTPreTrainedModel""",
  ]

try:
  if not is_flax_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  UpperCAmelCase__ :     str				    =    [
      """FlaxViTForImageClassification""",
      """FlaxViTModel""",
      """FlaxViTPreTrainedModel""",
  ]

if TYPE_CHECKING:
  from .configuration_vit import VIT_PRETRAINED_CONFIG_ARCHIVE_MAP, ViTConfig, ViTOnnxConfig

  try:
    if not is_vision_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .feature_extraction_vit import ViTFeatureExtractor
    from .image_processing_vit import ViTImageProcessor

  try:
    if not is_torch_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_vit import (
        VIT_PRETRAINED_MODEL_ARCHIVE_LIST,
        ViTForImageClassification,
        ViTForMaskedImageModeling,
        ViTModel,
        ViTPreTrainedModel,
    )

  try:
    if not is_tf_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_tf_vit import TFViTForImageClassification, TFViTModel, TFViTPreTrainedModel

  try:
    if not is_flax_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_flax_vit import FlaxViTForImageClassification, FlaxViTModel, FlaxViTPreTrainedModel


else:
  import sys

  UpperCAmelCase__ :     Optional[Any]				    =    _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)




