



'''simple docstring'''





from dataclasses import dataclass, field
from typing import Tuple

from ..utils import cached_property, is_torch_available, is_torch_tpu_available, logging, requires_backends
from .benchmark_args_utils import BenchmarkArguments


if is_torch_available():
  import torch

if is_torch_tpu_available(check_device=False):
  import torch_xla.core.xla_model as xm


lowercase_		       =  logging.get_logger(__name__)






@dataclass
class __A			(  A						):



 '''simple docstring'''







 __lowerCamelCase    :       str          =       [
     'no_inference',
     'no_cuda',
     'no_tpu',
     'no_speed',
     'no_memory',
     'no_env_print',
     'no_multi_process',
 ]



 def __init__(self ,   **A       )    ->     Union[str, Any]:


      """simple docstring"""



      for deprecated_arg in self.deprecated_args:
           if deprecated_arg in kwargs:
                _a      =  deprecated_arg[3:]
                setattr(self ,   A ,   not kwargs.pop(A       )       )
                logger.warning(
                    f'''{deprecated_arg} is depreciated. Please use --no_{positive_arg} or'''
                    f''' {positive_arg}={kwargs[positive_arg]}'''       )

      _a      =  kwargs.pop('''torchscript''' ,   self.torchscript       )
      _a      =  kwargs.pop('''torch_xla_tpu_print_metrics''' ,   self.torch_xla_tpu_print_metrics       )
      _a      =  kwargs.pop('''fp16_opt_level''' ,   self.fpaa_opt_level       )
      super().__init__(**A       )

 __lowerCamelCase    :       bool          =       field(default=A   ,   metadata={'help': 'Trace the models using torchscript'}						)
 __lowerCamelCase    :       bool          =       field(default=A   ,   metadata={'help': 'Print Xla/PyTorch tpu metrics'}						)
 __lowerCamelCase    :       str          =       field(
     default='O1'   ,   metadata={
         'help': (
             'For fp16: Apex AMP optimization level selected in [\'O0\', \'O1\', \'O2\', and \'O3\']. '
             'See details at https://nvidia.github.io/apex/amp.html'
         )
     }   ,   )



 @cached_property
 def 					a__  (self       )    ->     Tuple["torch.device", int]:


      """simple docstring"""



      requires_backends(self ,   ['''torch''']       )
      logger.info('''PyTorch: setting up devices'''       )
      if not self.cuda:
           _a      =  torch.device('''cpu'''       )
           _a      =  0
      elif is_torch_tpu_available():
           _a      =  xm.xla_device()
           _a      =  0
      else:
           _a      =  torch.device('''cuda''' if torch.cuda.is_available() else '''cpu'''       )
           _a      =  torch.cuda.device_count()
      return device, n_gpu



 @property
 def 					a__  (self       )    ->     Tuple:


      """simple docstring"""



      return is_torch_tpu_available() and self.tpu



 @property
 def 					a__  (self       )    ->     int:


      """simple docstring"""



      requires_backends(self ,   ['''torch''']       )
      # TODO(PVP): currently only single GPU is supported
      return torch.cuda.current_device()



 @property
 def 					a__  (self       )    ->     "torch.device":


      """simple docstring"""



      requires_backends(self ,   ['''torch''']       )
      return self._setup_devices[0]



 @property
 def 					a__  (self       )    ->     int:


      """simple docstring"""



      requires_backends(self ,   ['''torch''']       )
      return self._setup_devices[1]



 @property
 def 					a__  (self       )    ->     Optional[int]:


      """simple docstring"""



      return self.n_gpu > 0








'''simple docstring'''





from collections import OrderedDict
from typing import Mapping

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


lowercase_		       =  logging.get_logger(__name__)

lowercase_		       =  {
    "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 __A			(  A						):



 '''simple docstring'''







 __lowerCamelCase    :       Any          =       'xmod'



 def __init__(self ,   A=30_522 ,   A=768 ,   A=12 ,   A=12 ,   A=3_072 ,   A="gelu" ,   A=0.1 ,   A=0.1 ,   A=512 ,   A=2 ,   A=0.02 ,   A=1E-12 ,   A=1 ,   A=0 ,   A=2 ,   A="absolute" ,   A=True ,   A=None ,   A=False ,   A=2 ,   A=False ,   A=True ,   A=True ,   A=("en_XX",) ,   A=None ,   **A ,   )    ->     List[str]:


      """simple docstring"""



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

      _a      =  vocab_size
      _a      =  hidden_size
      _a      =  num_hidden_layers
      _a      =  num_attention_heads
      _a      =  hidden_act
      _a      =  intermediate_size
      _a      =  hidden_dropout_prob
      _a      =  attention_probs_dropout_prob
      _a      =  max_position_embeddings
      _a      =  type_vocab_size
      _a      =  initializer_range
      _a      =  layer_norm_eps
      _a      =  position_embedding_type
      _a      =  use_cache
      _a      =  classifier_dropout
      _a      =  pre_norm
      _a      =  adapter_reduction_factor
      _a      =  adapter_layer_norm
      _a      =  adapter_reuse_layer_norm
      _a      =  ln_before_adapter
      _a      =  list(A       )
      _a      =  default_language






class __A			(  A						):



 '''simple docstring'''







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


      """simple docstring"""



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



