






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							:   int							=  {
    "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 ):
	_A          =   'xlm'
	_A          =   {
	    'hidden_size': 'emb_dim',
	    'num_attention_heads': 'n_heads',
	    'num_hidden_layers': 'n_layers',
	    'n_words': 'vocab_size',  # For backward compatibility
	}






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

					if "n_words" in kwargs:
									snake_case__      :int         =   kwargs["n_words"]

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




class 					_snake_case						(			_A ):






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







from typing import List, Optional, Tuple

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_herbert import HerbertTokenizer


__UpperCAmelCase							:   str							=  logging.get_logger(__name__)

__UpperCAmelCase							:   List[Any]							=  {"vocab_file": "vocab.json", "merges_file": "merges.txt", "tokenizer_file": "tokenizer.json"}

__UpperCAmelCase							:   List[Any]							=  {
    "vocab_file": {
        "allegro/herbert-base-cased": "https://huggingface.co/allegro/herbert-base-cased/resolve/main/vocab.json"
    },
    "merges_file": {
        "allegro/herbert-base-cased": "https://huggingface.co/allegro/herbert-base-cased/resolve/main/merges.txt"
    },
}

__UpperCAmelCase							:   str							=  {"allegro/herbert-base-cased": 5_1_4}
__UpperCAmelCase							:   List[str]							=  {}


class 					_snake_case						(			_A ):
	_A          =   VOCAB_FILES_NAMES
	_A          =   PRETRAINED_VOCAB_FILES_MAP
	_A          =   PRETRAINED_INIT_CONFIGURATION
	_A          =   PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
	_A          =   HerbertTokenizer






	def __init__(		self					,UpperCamelCase=None					,UpperCamelCase=None					,UpperCamelCase=None					,UpperCamelCase="<s>"					,UpperCamelCase="<unk>"					,UpperCamelCase="<pad>"					,UpperCamelCase="<mask>"					,UpperCamelCase="</s>"					,**UpperCamelCase					,)						->    Dict:
					super().__init__(
					    UpperCamelCase					,UpperCamelCase					,tokenizer_file=UpperCamelCase					,cls_token=UpperCamelCase					,unk_token=UpperCamelCase					,pad_token=UpperCamelCase					,mask_token=UpperCamelCase					,sep_token=UpperCamelCase					,**UpperCamelCase					,)






	def    lowerCAmelCase_							(		self					,UpperCamelCase					,UpperCamelCase = None       )						->    List[int]:
					snake_case__      :Optional[int]         =   [self.cls_token_id]
					snake_case__      :Any         =   [self.sep_token_id]
					if token_ids_a is None:
									return cls + token_ids_a + sep

					return cls + token_ids_a + sep + token_ids_a + sep






	def    lowerCAmelCase_							(		self					,UpperCamelCase					,UpperCamelCase = None					,UpperCamelCase = False       )						->    List[int]:
					if already_has_special_tokens:
									return super().get_special_tokens_mask(
									    token_ids_a=UpperCamelCase					,token_ids_a=UpperCamelCase					,already_has_special_tokens=UpperCamelCase       )

					if token_ids_a is None:
									return [1] + ([0] * len(UpperCamelCase       )) + [1]
					return [1] + ([0] * len(UpperCamelCase       )) + [1] + ([0] * len(UpperCamelCase       )) + [1]






	def    lowerCAmelCase_							(		self					,UpperCamelCase					,UpperCamelCase = None       )						->    List[int]:
					snake_case__      :Any         =   [self.sep_token_id]
					snake_case__      :Union[str, Any]         =   [self.cls_token_id]

					if token_ids_a is None:
									return len(cls + token_ids_a + sep       ) * [0]
					return len(cls + token_ids_a + sep       ) * [0] + len(token_ids_a + sep       ) * [1]






	def    lowerCAmelCase_							(		self					,UpperCamelCase					,UpperCamelCase = None       )						->    Tuple[str]:
					snake_case__      :List[str]         =   self._tokenizer.model.save(UpperCamelCase					,name=UpperCamelCase       )
					return tuple(UpperCamelCase       )