



from collections import OrderedDict
from typing import Mapping

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


snake_case_           =      logging.get_logger(__name__)

snake_case_           =      {
    '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 		SCREAMING_SNAKE_CASE__    (	_UpperCAmelCase  ):
      A_						:    Union[str, Any]							=   'xlm'
      A_						:    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]    ,      a__	:				str=3_0145    ,      a__	:				str=2048    ,      a__	:				Dict=12    ,      a__	:				Any=16    ,      a__	:				Optional[int]=0.1    ,      a__	:				Any=0.1    ,      a__	:				str=True    ,      a__	:				int=False    ,      a__	:				List[str]=False    ,      a__	:				Optional[Any]=False    ,      a__	:				Any=1    ,      a__	:				Union[str, Any]=True    ,      a__	:				Optional[int]=512    ,      a__	:				int=2048**-0.5    ,      a__	:				int=1E-12    ,      a__	:				Optional[int]=0.0_2    ,      a__	:				str=0    ,      a__	:				Tuple=1    ,      a__	:				List[Any]=2    ,      a__	:				Optional[Any]=3    ,      a__	:				List[Any]=5    ,      a__	:				List[Any]=True    ,      a__	:				Any="first"    ,      a__	:				Any=True    ,      a__	:				Optional[int]=None    ,      a__	:				List[Any]=True    ,      a__	:				List[str]=0.1    ,      a__	:				Dict=5    ,      a__	:				Tuple=5    ,      a__	:				Optional[Any]=0    ,      a__	:				Union[str, Any]=0    ,      a__	:				Any=2    ,      a__	:				List[Any]=0    ,      **a__	:				int    ,      ):





         """simple docstring"""



         __snake_case								=       vocab_size
         __snake_case								=       emb_dim
         __snake_case								=       n_layers
         __snake_case								=       n_heads
         __snake_case								=       dropout
         __snake_case								=       attention_dropout
         __snake_case								=       gelu_activation
         __snake_case								=       sinusoidal_embeddings
         __snake_case								=       causal
         __snake_case								=       asm
         __snake_case								=       n_langs
         __snake_case								=       use_lang_emb
         __snake_case								=       layer_norm_eps
         __snake_case								=       bos_index
         __snake_case								=       eos_index
         __snake_case								=       pad_index
         __snake_case								=       unk_index
         __snake_case								=       mask_index
         __snake_case								=       is_encoder
         __snake_case								=       max_position_embeddings
         __snake_case								=       embed_init_std
         __snake_case								=       init_std
         __snake_case								=       summary_type
         __snake_case								=       summary_use_proj
         __snake_case								=       summary_activation
         __snake_case								=       summary_proj_to_labels
         __snake_case								=       summary_first_dropout
         __snake_case								=       start_n_top
         __snake_case								=       end_n_top
         __snake_case								=       mask_token_id
         __snake_case								=       lang_id

         if "n_words" in kwargs:
            __snake_case								=       kwargs['''n_words''']

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






class 		SCREAMING_SNAKE_CASE__    (	_UpperCAmelCase  ):


      @property
      def        a			(self	:				Any				):





         """simple docstring"""



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








class 		SCREAMING_SNAKE_CASE__    :


      def __init__(self	:				str    ,      a__	:				list				):





         """simple docstring"""



         __snake_case								=       set_counts
         __snake_case								=       max(a__				)
         __snake_case								=       len(a__				)
         __snake_case								=       [1] * num_sets
         __snake_case								=       list(range(a__				)				)


      def        a			(self	:				str    ,      a__	:				int    ,      a__	:				int				):





         """simple docstring"""



         __snake_case								=       self.get_parent(a__				)
         __snake_case								=       self.get_parent(a__				)

         if src_parent == dst_parent:
            return False

         if self.ranks[dst_parent] >= self.ranks[src_parent]:
            self.set_counts[dst_parent] += self.set_counts[src_parent]
            __snake_case								=       0
            __snake_case								=       dst_parent
            if self.ranks[dst_parent] == self.ranks[src_parent]:
               self.ranks[dst_parent] += 1
            __snake_case								=       self.set_counts[dst_parent]
         else:
            self.set_counts[src_parent] += self.set_counts[dst_parent]
            __snake_case								=       0
            __snake_case								=       src_parent
            __snake_case								=       self.set_counts[src_parent]

         __snake_case								=       max(self.max_set    ,      a__				)
         return True


      def        a			(self	:				Union[str, Any]    ,      a__	:				int				):





         """simple docstring"""



         if self.parents[disj_set] == disj_set:
            return disj_set
         __snake_case								=       self.get_parent(self.parents[disj_set]				)
         return self.parents[disj_set]

