

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


lowerCAmelCase							:  Dict            =						logging.get_logger(__name__)

lowerCAmelCase							:  Optional[int]            =						{
    '''transfo-xl-wt103''': '''https://huggingface.co/transfo-xl-wt103/resolve/main/config.json''',
}



class   __lowercase    (			a__     ):




			"""simple docstring"""







			_UpperCAmelCase       :							Tuple      							=					'transfo-xl'
			_UpperCAmelCase       :							List[Any]      							=					['mems']
			_UpperCAmelCase       :							str      							=					{
			    'n_token': 'vocab_size',
			    'hidden_size': 'd_model',
			    'num_attention_heads': 'n_head',
			    'num_hidden_layers': 'n_layer',
			}



			def __init__(			self  :					List[str]       ,						lowerCAmelCase__  :					Tuple=26_7735       ,						lowerCAmelCase__  :					Optional[Any]=[2_0000, 4_0000, 20_0000]       ,						lowerCAmelCase__  :					Tuple=1024       ,						lowerCAmelCase__  :					Dict=1024       ,						lowerCAmelCase__  :					int=16       ,						lowerCAmelCase__  :					List[str]=64       ,						lowerCAmelCase__  :					Optional[Any]=4096       ,						lowerCAmelCase__  :					Optional[int]=4       ,						lowerCAmelCase__  :					List[str]=False       ,						lowerCAmelCase__  :					Optional[int]=18       ,						lowerCAmelCase__  :					Any=1600       ,						lowerCAmelCase__  :					Union[str, Any]=1000       ,						lowerCAmelCase__  :					int=True       ,						lowerCAmelCase__  :					Union[str, Any]=True       ,						lowerCAmelCase__  :					Optional[Any]=0       ,						lowerCAmelCase__  :					Any=-1       ,						lowerCAmelCase__  :					Any=True       ,						lowerCAmelCase__  :					int=0.1       ,						lowerCAmelCase__  :					int=0.0       ,						lowerCAmelCase__  :					Any=True       ,						lowerCAmelCase__  :					Tuple="normal"       ,						lowerCAmelCase__  :					Optional[Any]=0.01       ,						lowerCAmelCase__  :					str=0.01       ,						lowerCAmelCase__  :					int=0.02       ,						lowerCAmelCase__  :					Dict=1E-5       ,						lowerCAmelCase__  :					int=0       ,						**lowerCAmelCase__  :					int       ,						):
									SCREAMING_SNAKE_CASE_:			List[str]   		=	vocab_size
									SCREAMING_SNAKE_CASE_:			str   		=	[]
									self.cutoffs.extend(_lowerCamelCase)
									if proj_share_all_but_first:
															SCREAMING_SNAKE_CASE_:			Optional[Any]   		=	[False] + [True] * len(self.cutoffs)
									else:
															SCREAMING_SNAKE_CASE_:			Union[str, Any]   		=	[False] + [False] * len(self.cutoffs)
									SCREAMING_SNAKE_CASE_:			List[str]   		=	d_model
									SCREAMING_SNAKE_CASE_:			Union[str, Any]   		=	d_embed
									SCREAMING_SNAKE_CASE_:			Tuple   		=	d_head
									SCREAMING_SNAKE_CASE_:			Any   		=	d_inner
									SCREAMING_SNAKE_CASE_:			Tuple   		=	div_val
									SCREAMING_SNAKE_CASE_:			Union[str, Any]   		=	pre_lnorm
									SCREAMING_SNAKE_CASE_:			Any   		=	n_layer
									SCREAMING_SNAKE_CASE_:			Any   		=	n_head
									SCREAMING_SNAKE_CASE_:			Any   		=	mem_len
									SCREAMING_SNAKE_CASE_:			Optional[int]   		=	same_length
									SCREAMING_SNAKE_CASE_:			Any   		=	attn_type
									SCREAMING_SNAKE_CASE_:			Dict   		=	clamp_len
									SCREAMING_SNAKE_CASE_:			Any   		=	sample_softmax
									SCREAMING_SNAKE_CASE_:			Optional[int]   		=	adaptive
									SCREAMING_SNAKE_CASE_:			str   		=	dropout
									SCREAMING_SNAKE_CASE_:			int   		=	dropatt
									SCREAMING_SNAKE_CASE_:			int   		=	untie_r
									SCREAMING_SNAKE_CASE_:			List[str]   		=	init
									SCREAMING_SNAKE_CASE_:			Tuple   		=	init_range
									SCREAMING_SNAKE_CASE_:			Tuple   		=	proj_init_std
									SCREAMING_SNAKE_CASE_:			Optional[int]   		=	init_std
									SCREAMING_SNAKE_CASE_:			List[str]   		=	layer_norm_epsilon
									super().__init__(eos_token_id=_lowerCamelCase       ,						**_lowerCamelCase)



			@property
			def 	_SCREAMING_SNAKE_CASE      (			self  :					Dict):
									# Message copied from Transformer-XL documentation
									logger.info(F"The model {self.model_type} is one of the few models that has no sequence length limit.")
									return -1




			@max_position_embeddings.setter
			def 	_SCREAMING_SNAKE_CASE      (			self  :					Optional[int]       ,						lowerCAmelCase__  :					Optional[int]):
									# Message copied from Transformer-XL documentation
									raise NotImplementedError(
									    F"The model {self.model_type} is one of the few models that has no sequence length limit.")









import json
from typing import List, Optional, Tuple

from tokenizers import normalizers

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_convbert import ConvBertTokenizer


lowerCAmelCase							:  Any            =						logging.get_logger(__name__)

lowerCAmelCase							:  Dict            =						{"""vocab_file""": """vocab.txt"""}

lowerCAmelCase							:  List[str]            =						{
    """vocab_file""": {
        """YituTech/conv-bert-base""": """https://huggingface.co/YituTech/conv-bert-base/resolve/main/vocab.txt""",
        """YituTech/conv-bert-medium-small""": (
            """https://huggingface.co/YituTech/conv-bert-medium-small/resolve/main/vocab.txt"""
        ),
        """YituTech/conv-bert-small""": """https://huggingface.co/YituTech/conv-bert-small/resolve/main/vocab.txt""",
    }
}

lowerCAmelCase							:  List[Any]            =						{
    """YituTech/conv-bert-base""": 512,
    """YituTech/conv-bert-medium-small""": 512,
    """YituTech/conv-bert-small""": 512,
}


lowerCAmelCase							:  Tuple            =						{
    """YituTech/conv-bert-base""": {"""do_lower_case""": True},
    """YituTech/conv-bert-medium-small""": {"""do_lower_case""": True},
    """YituTech/conv-bert-small""": {"""do_lower_case""": True},
}



class   __lowercase    (			UpperCAmelCase_     ):




			"""simple docstring"""







			_UpperCAmelCase       :							str      							=					VOCAB_FILES_NAMES
			_UpperCAmelCase       :							List[str]      							=					PRETRAINED_VOCAB_FILES_MAP
			_UpperCAmelCase       :							List[Any]      							=					PRETRAINED_INIT_CONFIGURATION
			_UpperCAmelCase       :							Optional[Any]      							=					PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
			_UpperCAmelCase       :							Dict      							=					ConvBertTokenizer



			def __init__(			self  :					Optional[Any]       ,						lowerCAmelCase__  :					Optional[int]=None       ,						lowerCAmelCase__  :					List[str]=None       ,						lowerCAmelCase__  :					str=True       ,						lowerCAmelCase__  :					Any="[UNK]"       ,						lowerCAmelCase__  :					Optional[Any]="[SEP]"       ,						lowerCAmelCase__  :					Any="[PAD]"       ,						lowerCAmelCase__  :					Dict="[CLS]"       ,						lowerCAmelCase__  :					Dict="[MASK]"       ,						lowerCAmelCase__  :					Tuple=True       ,						lowerCAmelCase__  :					str=None       ,						**lowerCAmelCase__  :					Dict       ,						):
									super().__init__(
									    lowerCAmelCase__       ,						tokenizer_file=lowerCAmelCase__       ,						do_lower_case=lowerCAmelCase__       ,						unk_token=lowerCAmelCase__       ,						sep_token=lowerCAmelCase__       ,						pad_token=lowerCAmelCase__       ,						cls_token=lowerCAmelCase__       ,						mask_token=lowerCAmelCase__       ,						tokenize_chinese_chars=lowerCAmelCase__       ,						strip_accents=lowerCAmelCase__       ,						**lowerCAmelCase__       ,						)

									SCREAMING_SNAKE_CASE_:			List[str]  		=	json.loads(self.backend_tokenizer.normalizer.__getstate__())
									if (
									    normalizer_state.get("lowercase"       ,						lowerCAmelCase__) != do_lower_case
									    or normalizer_state.get("strip_accents"       ,						lowerCAmelCase__) != strip_accents
									    or normalizer_state.get("handle_chinese_chars"       ,						lowerCAmelCase__) != tokenize_chinese_chars
									):
															SCREAMING_SNAKE_CASE_:			Optional[int]  		=	getattr(lowerCAmelCase__       ,						normalizer_state.pop("type"))
															SCREAMING_SNAKE_CASE_:			Optional[Any]  		=	do_lower_case
															SCREAMING_SNAKE_CASE_:			List[str]  		=	strip_accents
															SCREAMING_SNAKE_CASE_:			Optional[Any]  		=	tokenize_chinese_chars
															SCREAMING_SNAKE_CASE_:			Optional[int]  		=	normalizer_class(**lowerCAmelCase__)

									SCREAMING_SNAKE_CASE_:			Optional[int]  		=	do_lower_case



			def 	_SCREAMING_SNAKE_CASE      (			self  :					str       ,						lowerCAmelCase__  :					Optional[int]       ,						lowerCAmelCase__  :					Union[str, Any]=None):
									SCREAMING_SNAKE_CASE_:			List[str]  		=	[self.cls_token_id] + token_ids_a + [self.sep_token_id]

									if token_ids_a:
															output += token_ids_a + [self.sep_token_id]

									return output



			def 	_SCREAMING_SNAKE_CASE      (			self  :					Optional[Any]       ,						lowerCAmelCase__  :					List[int]       ,						lowerCAmelCase__  :					Optional[List[int]] = None):
									SCREAMING_SNAKE_CASE_:			Optional[int]  		=	[self.sep_token_id]
									SCREAMING_SNAKE_CASE_:			int  		=	[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 	_SCREAMING_SNAKE_CASE      (			self  :					List[Any]       ,						lowerCAmelCase__  :					str       ,						lowerCAmelCase__  :					Optional[str] = None):
									SCREAMING_SNAKE_CASE_:			Any  		=	self._tokenizer.model.save(lowerCAmelCase__       ,						name=lowerCAmelCase__)
									return tuple(lowerCAmelCase__)






