


from collections import OrderedDict
from typing import Mapping

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


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

_UpperCAmelCase			:  List[str]     ={
    """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 				snake_case__(							UpperCAmelCase__							):







						'''simple docstring'''




						SCREAMING_SNAKE_CASE__      :  Optional[int]					=							"""xlm"""
						SCREAMING_SNAKE_CASE__      :  List[str]					=							{
						    """hidden_size""": """emb_dim""",
						    """num_attention_heads""": """n_heads""",
						    """num_hidden_layers""": """n_layers""",
						    """n_words""": """vocab_size""",  # For backward compatibility
						}




						def __init__(				self   ,						__lowercase=3_0_1_4_5   ,						__lowercase=2_0_4_8   ,						__lowercase=1_2   ,						__lowercase=1_6   ,						__lowercase=0.1   ,						__lowercase=0.1   ,						__lowercase=True   ,						__lowercase=False   ,						__lowercase=False   ,						__lowercase=False   ,						__lowercase=1   ,						__lowercase=True   ,						__lowercase=5_1_2   ,						__lowercase=2_0_4_8**-0.5   ,						__lowercase=1e-12   ,						__lowercase=0.02   ,						__lowercase=0   ,						__lowercase=1   ,						__lowercase=2   ,						__lowercase=3   ,						__lowercase=5   ,						__lowercase=True   ,						__lowercase="first"   ,						__lowercase=True   ,						__lowercase=None   ,						__lowercase=True   ,						__lowercase=0.1   ,						__lowercase=5   ,						__lowercase=5   ,						__lowercase=0   ,						__lowercase=0   ,						__lowercase=2   ,						__lowercase=0   ,						**__lowercase   ,						)					->    Any:
										lowerCAmelCase_ :      List[Any]    				=				vocab_size
										lowerCAmelCase_ :      List[Any]    				=				emb_dim
										lowerCAmelCase_ :      Dict    				=				n_layers
										lowerCAmelCase_ :      int    				=				n_heads
										lowerCAmelCase_ :      str    				=				dropout
										lowerCAmelCase_ :      Optional[int]    				=				attention_dropout
										lowerCAmelCase_ :      str    				=				gelu_activation
										lowerCAmelCase_ :      Optional[Any]    				=				sinusoidal_embeddings
										lowerCAmelCase_ :      Optional[Any]    				=				causal
										lowerCAmelCase_ :      List[Any]    				=				asm
										lowerCAmelCase_ :      Dict    				=				n_langs
										lowerCAmelCase_ :      Dict    				=				use_lang_emb
										lowerCAmelCase_ :      int    				=				layer_norm_eps
										lowerCAmelCase_ :      Optional[Any]    				=				bos_index
										lowerCAmelCase_ :      str    				=				eos_index
										lowerCAmelCase_ :      str    				=				pad_index
										lowerCAmelCase_ :      Optional[int]    				=				unk_index
										lowerCAmelCase_ :      str    				=				mask_index
										lowerCAmelCase_ :      Tuple    				=				is_encoder
										lowerCAmelCase_ :      List[str]    				=				max_position_embeddings
										lowerCAmelCase_ :      List[Any]    				=				embed_init_std
										lowerCAmelCase_ :      Any    				=				init_std
										lowerCAmelCase_ :      List[Any]    				=				summary_type
										lowerCAmelCase_ :      Optional[Any]    				=				summary_use_proj
										lowerCAmelCase_ :      Tuple    				=				summary_activation
										lowerCAmelCase_ :      int    				=				summary_proj_to_labels
										lowerCAmelCase_ :      Union[str, Any]    				=				summary_first_dropout
										lowerCAmelCase_ :      Dict    				=				start_n_top
										lowerCAmelCase_ :      str    				=				end_n_top
										lowerCAmelCase_ :      Optional[Any]    				=				mask_token_id
										lowerCAmelCase_ :      int    				=				lang_id

										if "n_words" in kwargs:
														lowerCAmelCase_ :      Any    				=				kwargs['''n_words''']

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







class 				snake_case__(							UpperCAmelCase__							):







						'''simple docstring'''




						@property
						def 						lowercase_ (				self							)					->    Mapping[str, Mapping[int, str]]:
										if self.task == "multiple-choice":
														lowerCAmelCase_ :      Union[str, Any]    				=				{0: '''batch''', 1: '''choice''', 2: '''sequence'''}
										else:
														lowerCAmelCase_ :      Optional[Any]    				=				{0: '''batch''', 1: '''sequence'''}
										return OrderedDict(
										    [
										        ('''input_ids''', dynamic_axis),
										        ('''attention_mask''', dynamic_axis),
										        ('''token_type_ids''', dynamic_axis),
										    ]							)



import copy

from ...configuration_utils import PretrainedConfig
from ...utils import logging


_UpperCAmelCase			:  str     =logging.get_logger(__name__)







class 				snake_case__(							UpperCAmelCase__							):







						'''simple docstring'''




						SCREAMING_SNAKE_CASE__      :  Optional[int]					=							"""encoder-decoder"""
						SCREAMING_SNAKE_CASE__      :  str					=							True




						def __init__(				self   ,						**__lowercase							)					->    Union[str, Any]:
										super().__init__(**__lowercase							)
										assert (
										    "encoder" in kwargs and "decoder" in kwargs
										), "Config has to be initialized with encoder and decoder config"
										lowerCAmelCase_ :      str    				=				kwargs.pop('''encoder'''							)
										lowerCAmelCase_ :      int    				=				encoder_config.pop('''model_type'''							)
										lowerCAmelCase_ :      Optional[Any]    				=				kwargs.pop('''decoder'''							)
										lowerCAmelCase_ :      Optional[Any]    				=				decoder_config.pop('''model_type'''							)

										from ..auto.configuration_auto import AutoConfig

										lowerCAmelCase_ :      Union[str, Any]    				=				AutoConfig.for_model(__lowercase   ,						**__lowercase							)
										lowerCAmelCase_ :      List[str]    				=				AutoConfig.for_model(__lowercase   ,						**__lowercase							)
										lowerCAmelCase_ :      Any    				=				True




						@classmethod
						def 						lowercase_ (				cls   ,						__lowercase   ,						__lowercase   ,						**__lowercase							)					->    PretrainedConfig:
										logger.info('''Set `config.is_decoder=True` and `config.add_cross_attention=True` for decoder_config'''							)
										lowerCAmelCase_ :      int    				=				True
										lowerCAmelCase_ :      List[Any]    				=				True

										return cls(encoder=encoder_config.to_dict()   ,						decoder=decoder_config.to_dict()   ,						**__lowercase							)




						def 						lowercase_ (				self							)					->    Any:
										lowerCAmelCase_ :      Optional[Any]    				=				copy.deepcopy(self.__dict__							)
										lowerCAmelCase_ :      List[str]    				=				self.encoder.to_dict()
										lowerCAmelCase_ :      Dict    				=				self.decoder.to_dict()
										lowerCAmelCase_ :      Optional[Any]    				=				self.__class__.model_type
										return output