
'''simple docstring'''






from collections import OrderedDict
from typing import Mapping

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


A			      =      logging.get_logger(__name__)

A			      =      {
    '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		(   a__):
					_lowerCAmelCase			     =	'''xlm'''
					_lowerCAmelCase			     =	{
					    '''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"""


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

									if "n_words" in kwargs:
													lowerCamelCase					:			Union[str, Any]									= kwargs['n_words']

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





class     __snake_case		(   a__):
					@property
					def     UpperCAmelCase_							(     self      ):

									"""simple docstring"""


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





'''simple docstring'''






import importlib.metadata
import operator
import re
import sys
from typing import Optional

from packaging import version


A			      =      {
    '<': operator.lt,
    '<=': operator.le,
    '==': operator.eq,
    '!=': operator.ne,
    '>=': operator.ge,
    '>': operator.gt,
}





def    UpperCAmelCase							(  UpperCAmelCase__							:							Optional[Any]       ,							UpperCAmelCase__							:							Optional[Any]       ,							UpperCAmelCase__							:							Union[str, Any]       ,							UpperCAmelCase__							:							List[Any]       ,							UpperCAmelCase__							:							Dict       ,							UpperCAmelCase__							:							Optional[int]):
				if got_ver is None or want_ver is None:
								raise ValueError(
								    F'''Unable to compare versions for {requirement}: need={want_ver} found={got_ver}. This is unusual. Consider'''
								    F''' reinstalling {pkg}.''')
				if not ops[op](version.parse(UpperCAmelCase__)       ,							version.parse(UpperCAmelCase__)):
								raise ImportError(
								    F'''{requirement} is required for a normal functioning of this module, but found {pkg}=={got_ver}.{hint}''')





def    UpperCAmelCase							(  UpperCAmelCase__							:							str       ,							UpperCAmelCase__							:							Optional[str] = None):
				lowerCamelCase					:			List[Any]									= F'''\n{hint}''' if hint is not None else ''

				# non-versioned check
				if re.match(R'^[\w_\-\d]+$'       ,							UpperCAmelCase__):
								lowerCamelCase			, lowerCamelCase			, lowerCamelCase					:			Optional[Any]									= requirement, None, None
				else:
								lowerCamelCase					:			Optional[Any]									= re.findall(R'^([^!=<>\s]+)([\s!=<>]{1,2}.+)'       ,							UpperCAmelCase__)
								if not match:
												raise ValueError(
												    'requirement needs to be in the pip package format, .e.g., package_a==1.23, or package_b>=1.23, but'
												    F''' got {requirement}''')
								lowerCamelCase			, lowerCamelCase					:			Dict									= match[0]
								lowerCamelCase					:			Dict									= want_full.split(',')  # there could be multiple requirements
								lowerCamelCase					:			Union[str, Any]									= {}
								for w in want_range:
												lowerCamelCase					:			int									= re.findall(R'^([\s!=<>]{1,2})(.+)'       ,							UpperCAmelCase__)
												if not match:
																raise ValueError(
																    'requirement needs to be in the pip package format, .e.g., package_a==1.23, or package_b>=1.23,'
																    F''' but got {requirement}''')
												lowerCamelCase			, lowerCamelCase					:			List[Any]									= match[0]
												lowerCamelCase					:			Optional[int]									= want_ver
												if op not in ops:
																raise ValueError(F'''{requirement}: need one of {list(ops.keys())}, but got {op}''')

    # special case
				if pkg == "python":
								lowerCamelCase					:			Optional[int]									= '.'.join([str(UpperCAmelCase__) for x in sys.version_info[:3]])
								for op, want_ver in wanted.items():
												_compare_versions(UpperCAmelCase__       ,							UpperCAmelCase__       ,							UpperCAmelCase__       ,							UpperCAmelCase__       ,							UpperCAmelCase__       ,							UpperCAmelCase__)
								return

				# check if any version is installed
				try:
								lowerCamelCase					:			Any									= importlib.metadata.version(UpperCAmelCase__)
				except importlib.metadata.PackageNotFoundError:
								raise importlib.metadata.PackageNotFoundError(
								    F'''The \'{requirement}\' distribution was not found and is required by this application. {hint}''')

				# check that the right version is installed if version number or a range was provided
				if want_ver is not None:
								for op, want_ver in wanted.items():
												_compare_versions(UpperCAmelCase__       ,							UpperCAmelCase__       ,							UpperCAmelCase__       ,							UpperCAmelCase__       ,							UpperCAmelCase__       ,							UpperCAmelCase__)





def    UpperCAmelCase							(  UpperCAmelCase__							:							str):
				lowerCamelCase					:			List[str]									= 'Try: pip install transformers -U or pip install -e \'.[dev]\' if you\'re working with git main'
				return require_version(UpperCAmelCase__       ,							UpperCAmelCase__)
