





from collections import OrderedDict
from typing import Mapping

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


__lowerCamelCase :  Optional[Any]										=  logging.get_logger(__name__)

__lowerCamelCase :  Tuple										=  {
    """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__     ( __snake_case    ):
      _UpperCAmelCase			:Dict							=     'xlm'
      _UpperCAmelCase			:Dict							=     {
          'hidden_size': 'emb_dim',
          'num_attention_heads': 'n_heads',
          'num_hidden_layers': 'n_layers',
          'n_words': 'vocab_size',  # For backward compatibility
      }





      def __init__(				self ,							A_=3_0145 ,							A_=2048 ,							A_=12 ,							A_=16 ,							A_=0.1 ,							A_=0.1 ,							A_=True ,							A_=False ,							A_=False ,							A_=False ,							A_=1 ,							A_=True ,							A_=512 ,							A_=2048**-0.5 ,							A_=1e-12 ,							A_=0.02 ,							A_=0 ,							A_=1 ,							A_=2 ,							A_=3 ,							A_=5 ,							A_=True ,							A_="first" ,							A_=True ,							A_=None ,							A_=True ,							A_=0.1 ,							A_=5 ,							A_=5 ,							A_=0 ,							A_=0 ,							A_=2 ,							A_=0 ,							**A_ ,							):
       '''simple docstring'''




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

       if "n_words" in kwargs:
        UpperCamelCase			:      Any 			=     kwargs["n_words"]

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



class       A__     ( __snake_case    ):





      @property
      def  __UpperCamelCase(				self     ):
       '''simple docstring'''




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







import importlib
import sys
from argparse import REMAINDER, ArgumentParser
from pathlib import Path

import torch_xla.distributed.xla_multiprocessing as xmp



def 	A_       (  )		->				Dict:
 UpperCamelCase			:      Tuple 			=     ArgumentParser(
     description=(
         "PyTorch TPU distributed training launch "
         "helper utility that will spawn up "
         "multiple distributed processes"
     )  )

 # Optional arguments for the launch helper
 parser.add_argument("--num_cores"							,     type=_lowerCAmelCase							,     default=1							,     help="Number of TPU cores to use (1 or 8)."  )

 # positional
 parser.add_argument(
     "training_script"							,     type=_lowerCAmelCase							,     help=(
         "The full path to the single TPU training "
         "program/script to be launched in parallel, "
         "followed by all the arguments for the "
         "training script"
     )							,     )

 # rest from the training program
 parser.add_argument("training_script_args"							,     nargs=_lowerCAmelCase  )

 return parser.parse_args()



def 	A_       (  )		->				Optional[int]:
 UpperCamelCase			:      Tuple 			=     parse_args()

 # Import training_script as a module.
 UpperCamelCase			:      Union[str, Any] 			=     Path(args.training_script  )
 sys.path.append(str(script_fpath.parent.resolve()  )  )
 UpperCamelCase			:      List[Any] 			=     script_fpath.stem
 UpperCamelCase			:      Optional[Any] 			=     importlib.import_module(_lowerCAmelCase  )

 # Patch sys.argv
 UpperCamelCase			:      List[Any] 			=     [args.training_script] + args.training_script_args + ["--tpu_num_cores", str(args.num_cores  )]
 xmp.spawn(mod._mp_fn							,     args=()							,     nprocs=args.num_cores  )


if __name__ == "__main__":
    main()
