





"""simple docstring"""
import inspect
import unittest

from transformers import YolosConfig
from transformers.testing_utils import require_torch, require_vision, slow, torch_device
from transformers.utils import cached_property, is_torch_available, is_vision_available

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, floats_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
  import torch
  from torch import nn

  from transformers import YolosForObjectDetection, YolosModel
  from transformers.models.yolos.modeling_yolos import YOLOS_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
  from PIL import Image

  from transformers import AutoImageProcessor






class 					_SCREAMING_SNAKE_CASE:




       def __init__(						self		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__=13		,SCREAMING_SNAKE_CASE__=[30, 30]		,SCREAMING_SNAKE_CASE__=2		,SCREAMING_SNAKE_CASE__=3		,SCREAMING_SNAKE_CASE__=True		,SCREAMING_SNAKE_CASE__=True		,SCREAMING_SNAKE_CASE__=32		,SCREAMING_SNAKE_CASE__=5		,SCREAMING_SNAKE_CASE__=4		,SCREAMING_SNAKE_CASE__=37		,SCREAMING_SNAKE_CASE__="gelu"		,SCREAMING_SNAKE_CASE__=0.1		,SCREAMING_SNAKE_CASE__=0.1		,SCREAMING_SNAKE_CASE__=10		,SCREAMING_SNAKE_CASE__=0.0_2		,SCREAMING_SNAKE_CASE__=3		,SCREAMING_SNAKE_CASE__=None		,SCREAMING_SNAKE_CASE__=8		,SCREAMING_SNAKE_CASE__=10		,)			->      Optional[int]:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :Tuple						=  parent
             __SCREAMING_SNAKE_CASE   :List[Any]						=  batch_size
             __SCREAMING_SNAKE_CASE   :int						=  image_size
             __SCREAMING_SNAKE_CASE   :int						=  patch_size
             __SCREAMING_SNAKE_CASE   :int						=  num_channels
             __SCREAMING_SNAKE_CASE   :Optional[Any]						=  is_training
             __SCREAMING_SNAKE_CASE   :List[str]						=  use_labels
             __SCREAMING_SNAKE_CASE   :List[Any]						=  hidden_size
             __SCREAMING_SNAKE_CASE   :str						=  num_hidden_layers
             __SCREAMING_SNAKE_CASE   :Tuple						=  num_attention_heads
             __SCREAMING_SNAKE_CASE   :List[str]						=  intermediate_size
             __SCREAMING_SNAKE_CASE   :Optional[Any]						=  hidden_act
             __SCREAMING_SNAKE_CASE   :int						=  hidden_dropout_prob
             __SCREAMING_SNAKE_CASE   :Optional[Any]						=  attention_probs_dropout_prob
             __SCREAMING_SNAKE_CASE   :str						=  type_sequence_label_size
             __SCREAMING_SNAKE_CASE   :Dict						=  initializer_range
             __SCREAMING_SNAKE_CASE   :Tuple						=  num_labels
             __SCREAMING_SNAKE_CASE   :Dict						=  scope
             __SCREAMING_SNAKE_CASE   :Dict						=  n_targets
             __SCREAMING_SNAKE_CASE   :Optional[Any]						=  num_detection_tokens
             # we set the expected sequence length (which is used in several tests)
             # expected sequence length = num_patches + 1 (we add 1 for the [CLS] token) + num_detection_tokens
             __SCREAMING_SNAKE_CASE   :str						=  (image_size[1] // patch_size) * (image_size[0] // patch_size)
             __SCREAMING_SNAKE_CASE   :Dict						=  num_patches + 1 + self.num_detection_tokens




       def     _UpperCamelCase     (						self							)			->      Tuple:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :str						=  floats_tensor([self.batch_size, self.num_channels, self.image_size[0], self.image_size[1]]							)

             __SCREAMING_SNAKE_CASE   :Union[str, Any]						=  None
             if self.use_labels:
                   # labels is a list of Dict (each Dict being the labels for a given example in the batch)
                   __SCREAMING_SNAKE_CASE   :Any						=  []
                   for i in range(self.batch_size							):
                         __SCREAMING_SNAKE_CASE   :Dict						=  {}
                         __SCREAMING_SNAKE_CASE   :Union[str, Any]						=  torch.randint(
                             high=self.num_labels		,size=(self.n_targets,)		,device=SCREAMING_SNAKE_CASE__							)
                         __SCREAMING_SNAKE_CASE   :Dict						=  torch.rand(self.n_targets		,4		,device=SCREAMING_SNAKE_CASE__							)
                         labels.append(SCREAMING_SNAKE_CASE__							)

             __SCREAMING_SNAKE_CASE   :Union[str, Any]						=  self.get_config()

             return config, pixel_values, labels




       def     _UpperCamelCase     (						self							)			->      Optional[Any]:





             """simple docstring"""






             return YolosConfig(
                 image_size=self.image_size		,patch_size=self.patch_size		,num_channels=self.num_channels		,hidden_size=self.hidden_size		,num_hidden_layers=self.num_hidden_layers		,num_attention_heads=self.num_attention_heads		,intermediate_size=self.intermediate_size		,hidden_act=self.hidden_act		,hidden_dropout_prob=self.hidden_dropout_prob		,attention_probs_dropout_prob=self.attention_probs_dropout_prob		,is_decoder=SCREAMING_SNAKE_CASE__		,initializer_range=self.initializer_range		,num_detection_tokens=self.num_detection_tokens		,num_labels=self.num_labels		,)




       def     _UpperCamelCase     (						self		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__							)			->      int:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :Optional[int]						=  YolosModel(config=SCREAMING_SNAKE_CASE__							)
             model.to(SCREAMING_SNAKE_CASE__							)
             model.eval()
             __SCREAMING_SNAKE_CASE   :Dict						=  model(SCREAMING_SNAKE_CASE__							)
             self.parent.assertEqual(
                 result.last_hidden_state.shape		,(self.batch_size, self.expected_seq_len, self.hidden_size)							)




       def     _UpperCamelCase     (						self		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__							)			->      Optional[Any]:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :int						=  YolosForObjectDetection(SCREAMING_SNAKE_CASE__							)
             model.to(SCREAMING_SNAKE_CASE__							)
             model.eval()

             __SCREAMING_SNAKE_CASE   :Optional[int]						=  model(pixel_values=SCREAMING_SNAKE_CASE__							)
             __SCREAMING_SNAKE_CASE   :Optional[Any]						=  model(SCREAMING_SNAKE_CASE__							)

             self.parent.assertEqual(result.logits.shape		,(self.batch_size, self.num_detection_tokens, self.num_labels + 1)							)
             self.parent.assertEqual(result.pred_boxes.shape		,(self.batch_size, self.num_detection_tokens, 4)							)

             __SCREAMING_SNAKE_CASE   :Optional[Any]						=  model(pixel_values=SCREAMING_SNAKE_CASE__		,labels=SCREAMING_SNAKE_CASE__							)

             self.parent.assertEqual(result.loss.shape		,()							)
             self.parent.assertEqual(result.logits.shape		,(self.batch_size, self.num_detection_tokens, self.num_labels + 1)							)
             self.parent.assertEqual(result.pred_boxes.shape		,(self.batch_size, self.num_detection_tokens, 4)							)




       def     _UpperCamelCase     (						self							)			->      List[Any]:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :List[Any]						=  self.prepare_config_and_inputs()
             __SCREAMING_SNAKE_CASE				,__SCREAMING_SNAKE_CASE				,__SCREAMING_SNAKE_CASE   :Optional[int]						=  config_and_inputs
             __SCREAMING_SNAKE_CASE   :Optional[int]						=  {'''pixel_values''': pixel_values}
             return config, inputs_dict






@require_torch
class 					_SCREAMING_SNAKE_CASE(   A    ,	A    ,	unittest.TestCase  ):
       SCREAMING_SNAKE_CASE_   :      Dict							=  (YolosModel, YolosForObjectDetection) if is_torch_available() else ()
       SCREAMING_SNAKE_CASE_   :      Dict							=  (
           {'''feature-extraction''': YolosModel, '''object-detection''': YolosForObjectDetection} if is_torch_available() else {}
       )

       SCREAMING_SNAKE_CASE_   :      Dict							=  False
       SCREAMING_SNAKE_CASE_   :      Union[str, Any]							=  False
       SCREAMING_SNAKE_CASE_   :      Optional[int]							=  False
       SCREAMING_SNAKE_CASE_   :      Tuple							=  False




       def     _UpperCamelCase     (						self		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__=False							)			->      Tuple:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :str						=  super()._prepare_for_class(SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,return_labels=SCREAMING_SNAKE_CASE__							)

             if return_labels:
                   if model_class.__name__ == "YolosForObjectDetection":
                         __SCREAMING_SNAKE_CASE   :Dict						=  []
                         for i in range(self.model_tester.batch_size							):
                               __SCREAMING_SNAKE_CASE   :Union[str, Any]						=  {}
                               __SCREAMING_SNAKE_CASE   :Optional[Any]						=  torch.ones(
                                   size=(self.model_tester.n_targets,)		,device=SCREAMING_SNAKE_CASE__		,dtype=torch.long							)
                               __SCREAMING_SNAKE_CASE   :Optional[Any]						=  torch.ones(
                                   self.model_tester.n_targets		,4		,device=SCREAMING_SNAKE_CASE__		,dtype=torch.float							)
                               labels.append(SCREAMING_SNAKE_CASE__							)
                         __SCREAMING_SNAKE_CASE   :List[str]						=  labels

             return inputs_dict




       def     _UpperCamelCase     (						self							)			->      Tuple:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :int						=  YolosModelTester(self							)
             __SCREAMING_SNAKE_CASE   :Optional[Any]						=  ConfigTester(self		,config_class=SCREAMING_SNAKE_CASE__		,has_text_modality=SCREAMING_SNAKE_CASE__		,hidden_size=37							)




       def     _UpperCamelCase     (						self							)			->      Optional[Any]:





             """simple docstring"""






             self.config_tester.run_common_tests()




       def     _UpperCamelCase     (						self							)			->      Dict:





             """simple docstring"""






             pass




       def     _UpperCamelCase     (						self							)			->      List[Any]:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE				,__SCREAMING_SNAKE_CASE   :List[Any]						=  self.model_tester.prepare_config_and_inputs_for_common()

             for model_class in self.all_model_classes:
                   __SCREAMING_SNAKE_CASE   :Optional[int]						=  model_class(SCREAMING_SNAKE_CASE__							)
                   self.assertIsInstance(model.get_input_embeddings()		,(nn.Module)							)
                   __SCREAMING_SNAKE_CASE   :List[str]						=  model.get_output_embeddings()
                   self.assertTrue(x is None or isinstance(SCREAMING_SNAKE_CASE__		,nn.Linear							)							)




       def     _UpperCamelCase     (						self							)			->      Any:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE				,__SCREAMING_SNAKE_CASE   :Optional[Any]						=  self.model_tester.prepare_config_and_inputs_for_common()

             for model_class in self.all_model_classes:
                   __SCREAMING_SNAKE_CASE   :Union[str, Any]						=  model_class(SCREAMING_SNAKE_CASE__							)
                   __SCREAMING_SNAKE_CASE   :Union[str, Any]						=  inspect.signature(model.forward							)
                   # signature.parameters is an OrderedDict => so arg_names order is deterministic
                   __SCREAMING_SNAKE_CASE   :Optional[Any]						=  [*signature.parameters.keys()]

                   __SCREAMING_SNAKE_CASE   :Union[str, Any]						=  ['''pixel_values''']
                   self.assertListEqual(arg_names[:1]		,SCREAMING_SNAKE_CASE__							)




       def     _UpperCamelCase     (						self							)			->      List[str]:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :Dict						=  self.model_tester.prepare_config_and_inputs()
             self.model_tester.create_and_check_model(*SCREAMING_SNAKE_CASE__							)




       def     _UpperCamelCase     (						self							)			->      List[Any]:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE				,__SCREAMING_SNAKE_CASE   :int						=  self.model_tester.prepare_config_and_inputs_for_common()
             __SCREAMING_SNAKE_CASE   :int						=  True

             # in YOLOS, the seq_len is different
             __SCREAMING_SNAKE_CASE   :Optional[int]						=  self.model_tester.expected_seq_len
             for model_class in self.all_model_classes:
                   __SCREAMING_SNAKE_CASE   :str						=  True
                   __SCREAMING_SNAKE_CASE   :int						=  False
                   __SCREAMING_SNAKE_CASE   :Optional[Any]						=  True
                   __SCREAMING_SNAKE_CASE   :int						=  model_class(SCREAMING_SNAKE_CASE__							)
                   model.to(SCREAMING_SNAKE_CASE__							)
                   model.eval()
                   with torch.no_grad():
                         __SCREAMING_SNAKE_CASE   :str						=  model(**self._prepare_for_class(SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__							)							)
                   __SCREAMING_SNAKE_CASE   :Tuple						=  outputs.attentions
                   self.assertEqual(len(SCREAMING_SNAKE_CASE__							)		,self.model_tester.num_hidden_layers							)

                   # check that output_attentions also work using config
                   del inputs_dict["output_attentions"]
                   __SCREAMING_SNAKE_CASE   :List[str]						=  True
                   __SCREAMING_SNAKE_CASE   :List[Any]						=  model_class(SCREAMING_SNAKE_CASE__							)
                   model.to(SCREAMING_SNAKE_CASE__							)
                   model.eval()
                   with torch.no_grad():
                         __SCREAMING_SNAKE_CASE   :Any						=  model(**self._prepare_for_class(SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__							)							)
                   __SCREAMING_SNAKE_CASE   :Tuple						=  outputs.attentions
                   self.assertEqual(len(SCREAMING_SNAKE_CASE__							)		,self.model_tester.num_hidden_layers							)

                   self.assertListEqual(
                       list(attentions[0].shape[-3:]							)		,[self.model_tester.num_attention_heads, seq_len, seq_len]		,)
                   __SCREAMING_SNAKE_CASE   :List[str]						=  len(SCREAMING_SNAKE_CASE__							)

                   # Check attention is always last and order is fine
                   __SCREAMING_SNAKE_CASE   :str						=  True
                   __SCREAMING_SNAKE_CASE   :Union[str, Any]						=  True
                   __SCREAMING_SNAKE_CASE   :Union[str, Any]						=  model_class(SCREAMING_SNAKE_CASE__							)
                   model.to(SCREAMING_SNAKE_CASE__							)
                   model.eval()
                   with torch.no_grad():
                         __SCREAMING_SNAKE_CASE   :List[str]						=  model(**self._prepare_for_class(SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__							)							)

                   __SCREAMING_SNAKE_CASE   :Dict						=  1
                   self.assertEqual(out_len + added_hidden_states		,len(SCREAMING_SNAKE_CASE__							)							)

                   __SCREAMING_SNAKE_CASE   :Optional[int]						=  outputs.attentions

                   self.assertEqual(len(SCREAMING_SNAKE_CASE__							)		,self.model_tester.num_hidden_layers							)
                   self.assertListEqual(
                       list(self_attentions[0].shape[-3:]							)		,[self.model_tester.num_attention_heads, seq_len, seq_len]		,)




       def     _UpperCamelCase     (						self							)			->      Optional[int]:





             """simple docstring"""






             def check_hidden_states_output(SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__							):
                   __SCREAMING_SNAKE_CASE   :Any						=  model_class(SCREAMING_SNAKE_CASE__							)
                   model.to(SCREAMING_SNAKE_CASE__							)
                   model.eval()

                   with torch.no_grad():
                         __SCREAMING_SNAKE_CASE   :Optional[Any]						=  model(**self._prepare_for_class(SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__							)							)

                   __SCREAMING_SNAKE_CASE   :Tuple						=  outputs.hidden_states

                   __SCREAMING_SNAKE_CASE   :List[str]						=  getattr(
                       self.model_tester		,'''expected_num_hidden_layers'''		,self.model_tester.num_hidden_layers + 1							)
                   self.assertEqual(len(SCREAMING_SNAKE_CASE__							)		,SCREAMING_SNAKE_CASE__							)

                   # YOLOS has a different seq_length
                   __SCREAMING_SNAKE_CASE   :Optional[Any]						=  self.model_tester.expected_seq_len

                   self.assertListEqual(
                       list(hidden_states[0].shape[-2:]							)		,[seq_length, self.model_tester.hidden_size]		,)

             __SCREAMING_SNAKE_CASE				,__SCREAMING_SNAKE_CASE   :Tuple						=  self.model_tester.prepare_config_and_inputs_for_common()

             for model_class in self.all_model_classes:
                   __SCREAMING_SNAKE_CASE   :int						=  True
                   check_hidden_states_output(SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__							)

                   # check that output_hidden_states also work using config
                   del inputs_dict["output_hidden_states"]
                   __SCREAMING_SNAKE_CASE   :Any						=  True

                   check_hidden_states_output(SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__							)




       def     _UpperCamelCase     (						self							)			->      Any:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :int						=  self.model_tester.prepare_config_and_inputs()
             self.model_tester.create_and_check_for_object_detection(*SCREAMING_SNAKE_CASE__							)




       @slow
       def     _UpperCamelCase     (						self							)			->      Optional[int]:





             """simple docstring"""






             for model_name in YOLOS_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
                   __SCREAMING_SNAKE_CASE   :Optional[Any]						=  YolosModel.from_pretrained(SCREAMING_SNAKE_CASE__							)
                   self.assertIsNotNone(SCREAMING_SNAKE_CASE__							)




def      __lowerCamelCase   (							)			->      str:
      __SCREAMING_SNAKE_CASE   :Union[str, Any]						=  Image.open('''./tests/fixtures/tests_samples/COCO/000000039769.png'''							)
      return image







@require_torch
@require_vision
class 					_SCREAMING_SNAKE_CASE(   unittest.TestCase  ):




       @cached_property
       def     _UpperCamelCase     (						self							)			->      Optional[Any]:





             """simple docstring"""






             return AutoImageProcessor.from_pretrained('''hustvl/yolos-small'''							) if is_vision_available() else None




       @slow
       def     _UpperCamelCase     (						self							)			->      str:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :Optional[Any]						=  YolosForObjectDetection.from_pretrained('''hustvl/yolos-small'''							).to(SCREAMING_SNAKE_CASE__							)

             __SCREAMING_SNAKE_CASE   :Any						=  self.default_image_processor
             __SCREAMING_SNAKE_CASE   :List[str]						=  prepare_img()
             __SCREAMING_SNAKE_CASE   :List[Any]						=  image_processor(images=SCREAMING_SNAKE_CASE__		,return_tensors='''pt'''							).to(SCREAMING_SNAKE_CASE__							)

             # forward pass
             with torch.no_grad():
                   __SCREAMING_SNAKE_CASE   :Union[str, Any]						=  model(inputs.pixel_values							)

             # verify outputs
             __SCREAMING_SNAKE_CASE   :Optional[Any]						=  torch.Size((1, 1_00, 92)							)
             self.assertEqual(outputs.logits.shape		,SCREAMING_SNAKE_CASE__							)

             __SCREAMING_SNAKE_CASE   :str						=  torch.tensor(
                 [[-2_4.0_2_4_8, -1_0.3_0_2_4, -1_4.8_2_9_0], [-4_2.0_3_9_2, -1_6.8_2_0_0, -2_7.4_3_3_4], [-2_7.2_7_4_3, -1_1.8_1_5_4, -1_8.7_1_4_8]]		,device=SCREAMING_SNAKE_CASE__		,)
             __SCREAMING_SNAKE_CASE   :int						=  torch.tensor(
                 [[0.2_5_5_9, 0.5_4_5_5, 0.4_7_0_6], [0.2_9_8_9, 0.7_2_7_9, 0.1_8_7_5], [0.7_7_3_2, 0.4_0_1_7, 0.4_4_6_2]]		,device=SCREAMING_SNAKE_CASE__							)
             self.assertTrue(torch.allclose(outputs.logits[0, :3, :3]		,SCREAMING_SNAKE_CASE__		,atol=1E-4							)							)
             self.assertTrue(torch.allclose(outputs.pred_boxes[0, :3, :3]		,SCREAMING_SNAKE_CASE__		,atol=1E-4							)							)

             # verify postprocessing
             __SCREAMING_SNAKE_CASE   :Any						=  image_processor.post_process_object_detection(
                 SCREAMING_SNAKE_CASE__		,threshold=0.3		,target_sizes=[image.size[::-1]]							)[0]
             __SCREAMING_SNAKE_CASE   :Any						=  torch.tensor([0.9_9_9_4, 0.9_7_9_0, 0.9_9_6_4, 0.9_9_7_2, 0.9_8_6_1]							).to(SCREAMING_SNAKE_CASE__							)
             __SCREAMING_SNAKE_CASE   :int						=  [75, 75, 17, 63, 17]
             __SCREAMING_SNAKE_CASE   :List[str]						=  torch.tensor([3_3_5.0_6_0_9, 7_9.3_8_4_8, 3_7_5.4_2_1_6, 1_8_7.2_4_9_5]							).to(SCREAMING_SNAKE_CASE__							)

             self.assertEqual(len(results['''scores''']							)		,5							)
             self.assertTrue(torch.allclose(results['''scores''']		,SCREAMING_SNAKE_CASE__		,atol=1E-4							)							)
             self.assertSequenceEqual(results['''labels'''].tolist()		,SCREAMING_SNAKE_CASE__							)
             self.assertTrue(torch.allclose(results['''boxes'''][0, :]		,SCREAMING_SNAKE_CASE__							)							)






"""simple docstring"""
from collections import OrderedDict
from typing import Mapping

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


lowerCamelCase_								=		logging.get_logger(__name__)

lowerCamelCase_								=		{
    "facebook/xmod-base": "https://huggingface.co/facebook/xmod-base/resolve/main/config.json",
    "facebook/xmod-large-prenorm": "https://huggingface.co/facebook/xmod-large-prenorm/resolve/main/config.json",
    "facebook/xmod-base-13-125k": "https://huggingface.co/facebook/xmod-base-13-125k/resolve/main/config.json",
    "facebook/xmod-base-30-125k": "https://huggingface.co/facebook/xmod-base-30-125k/resolve/main/config.json",
    "facebook/xmod-base-30-195k": "https://huggingface.co/facebook/xmod-base-30-195k/resolve/main/config.json",
    "facebook/xmod-base-60-125k": "https://huggingface.co/facebook/xmod-base-60-125k/resolve/main/config.json",
    "facebook/xmod-base-60-265k": "https://huggingface.co/facebook/xmod-base-60-265k/resolve/main/config.json",
    "facebook/xmod-base-75-125k": "https://huggingface.co/facebook/xmod-base-75-125k/resolve/main/config.json",
    "facebook/xmod-base-75-269k": "https://huggingface.co/facebook/xmod-base-75-269k/resolve/main/config.json",
}






class 					_SCREAMING_SNAKE_CASE(   A  ):
       SCREAMING_SNAKE_CASE_   :      Any							=  '''xmod'''




       def __init__(						self		,SCREAMING_SNAKE_CASE__=3_05_22		,SCREAMING_SNAKE_CASE__=7_68		,SCREAMING_SNAKE_CASE__=12		,SCREAMING_SNAKE_CASE__=12		,SCREAMING_SNAKE_CASE__=30_72		,SCREAMING_SNAKE_CASE__="gelu"		,SCREAMING_SNAKE_CASE__=0.1		,SCREAMING_SNAKE_CASE__=0.1		,SCREAMING_SNAKE_CASE__=5_12		,SCREAMING_SNAKE_CASE__=2		,SCREAMING_SNAKE_CASE__=0.0_2		,SCREAMING_SNAKE_CASE__=1E-12		,SCREAMING_SNAKE_CASE__=1		,SCREAMING_SNAKE_CASE__=0		,SCREAMING_SNAKE_CASE__=2		,SCREAMING_SNAKE_CASE__="absolute"		,SCREAMING_SNAKE_CASE__=True		,SCREAMING_SNAKE_CASE__=None		,SCREAMING_SNAKE_CASE__=False		,SCREAMING_SNAKE_CASE__=2		,SCREAMING_SNAKE_CASE__=False		,SCREAMING_SNAKE_CASE__=True		,SCREAMING_SNAKE_CASE__=True		,SCREAMING_SNAKE_CASE__=("en_XX",)		,SCREAMING_SNAKE_CASE__=None		,**SCREAMING_SNAKE_CASE__		,)			->      Optional[Any]:





             """simple docstring"""






             super().__init__(pad_token_id=SCREAMING_SNAKE_CASE__		,bos_token_id=SCREAMING_SNAKE_CASE__		,eos_token_id=SCREAMING_SNAKE_CASE__		,**SCREAMING_SNAKE_CASE__							)

             __SCREAMING_SNAKE_CASE   :Optional[int]						=  vocab_size
             __SCREAMING_SNAKE_CASE   :List[Any]						=  hidden_size
             __SCREAMING_SNAKE_CASE   :List[str]						=  num_hidden_layers
             __SCREAMING_SNAKE_CASE   :List[str]						=  num_attention_heads
             __SCREAMING_SNAKE_CASE   :Optional[int]						=  hidden_act
             __SCREAMING_SNAKE_CASE   :Tuple						=  intermediate_size
             __SCREAMING_SNAKE_CASE   :Dict						=  hidden_dropout_prob
             __SCREAMING_SNAKE_CASE   :str						=  attention_probs_dropout_prob
             __SCREAMING_SNAKE_CASE   :Optional[Any]						=  max_position_embeddings
             __SCREAMING_SNAKE_CASE   :Optional[Any]						=  type_vocab_size
             __SCREAMING_SNAKE_CASE   :str						=  initializer_range
             __SCREAMING_SNAKE_CASE   :List[Any]						=  layer_norm_eps
             __SCREAMING_SNAKE_CASE   :Optional[Any]						=  position_embedding_type
             __SCREAMING_SNAKE_CASE   :Any						=  use_cache
             __SCREAMING_SNAKE_CASE   :List[str]						=  classifier_dropout
             __SCREAMING_SNAKE_CASE   :Any						=  pre_norm
             __SCREAMING_SNAKE_CASE   :Dict						=  adapter_reduction_factor
             __SCREAMING_SNAKE_CASE   :Dict						=  adapter_layer_norm
             __SCREAMING_SNAKE_CASE   :Dict						=  adapter_reuse_layer_norm
             __SCREAMING_SNAKE_CASE   :Tuple						=  ln_before_adapter
             __SCREAMING_SNAKE_CASE   :Any						=  list(SCREAMING_SNAKE_CASE__							)
             __SCREAMING_SNAKE_CASE   :Optional[Any]						=  default_language






class 					_SCREAMING_SNAKE_CASE(   A  ):




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





             """simple docstring"""






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