


from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


_UpperCAmelCase			:  str     ={
    'configuration_convbert': ['CONVBERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'ConvBertConfig', 'ConvBertOnnxConfig'],
    'tokenization_convbert': ['ConvBertTokenizer'],
}

try:
						if not is_tokenizers_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						_UpperCAmelCase			:  Optional[int]     =['ConvBertTokenizerFast']

try:
						if not is_torch_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						_UpperCAmelCase			:  str     =[
						    'CONVBERT_PRETRAINED_MODEL_ARCHIVE_LIST',
						    'ConvBertForMaskedLM',
						    'ConvBertForMultipleChoice',
						    'ConvBertForQuestionAnswering',
						    'ConvBertForSequenceClassification',
						    'ConvBertForTokenClassification',
						    'ConvBertLayer',
						    'ConvBertModel',
						    'ConvBertPreTrainedModel',
						    'load_tf_weights_in_convbert',
						]


try:
						if not is_tf_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						_UpperCAmelCase			:  Dict     =[
						    'TF_CONVBERT_PRETRAINED_MODEL_ARCHIVE_LIST',
						    'TFConvBertForMaskedLM',
						    'TFConvBertForMultipleChoice',
						    'TFConvBertForQuestionAnswering',
						    'TFConvBertForSequenceClassification',
						    'TFConvBertForTokenClassification',
						    'TFConvBertLayer',
						    'TFConvBertModel',
						    'TFConvBertPreTrainedModel',
						]


if TYPE_CHECKING:
						from .configuration_convbert import CONVBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, ConvBertConfig, ConvBertOnnxConfig
						from .tokenization_convbert import ConvBertTokenizer

						try:
												if not is_tokenizers_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .tokenization_convbert_fast import ConvBertTokenizerFast

						try:
												if not is_torch_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .modeling_convbert import (
												    CONVBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
												    ConvBertForMaskedLM,
												    ConvBertForMultipleChoice,
												    ConvBertForQuestionAnswering,
												    ConvBertForSequenceClassification,
												    ConvBertForTokenClassification,
												    ConvBertLayer,
												    ConvBertModel,
												    ConvBertPreTrainedModel,
												    load_tf_weights_in_convbert,
												)

						try:
												if not is_tf_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .modeling_tf_convbert import (
												    TF_CONVBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
												    TFConvBertForMaskedLM,
												    TFConvBertForMultipleChoice,
												    TFConvBertForQuestionAnswering,
												    TFConvBertForSequenceClassification,
												    TFConvBertForTokenClassification,
												    TFConvBertLayer,
												    TFConvBertModel,
												    TFConvBertPreTrainedModel,
												)


else:
						import sys

						_UpperCAmelCase			:  Any     =_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)



import os
from shutil import copyfile
from typing import List, Optional, Tuple

from ...tokenization_utils import AddedToken
from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import is_sentencepiece_available, logging


if is_sentencepiece_available():
						from .tokenization_xlnet import XLNetTokenizer
else:
						_UpperCAmelCase			:  Dict     =None


_UpperCAmelCase			:  Tuple     =logging.get_logger(__name__)

_UpperCAmelCase			:  Any     ={"""vocab_file""": """spiece.model""", """tokenizer_file""": """tokenizer.json"""}

_UpperCAmelCase			:  Any     ={
    """vocab_file""": {
        """xlnet-base-cased""": """https://huggingface.co/xlnet-base-cased/resolve/main/spiece.model""",
        """xlnet-large-cased""": """https://huggingface.co/xlnet-large-cased/resolve/main/spiece.model""",
    },
    """tokenizer_file""": {
        """xlnet-base-cased""": """https://huggingface.co/xlnet-base-cased/resolve/main/tokenizer.json""",
        """xlnet-large-cased""": """https://huggingface.co/xlnet-large-cased/resolve/main/tokenizer.json""",
    },
}

_UpperCAmelCase			:  Dict     ={
    """xlnet-base-cased""": None,
    """xlnet-large-cased""": None,
}

_UpperCAmelCase			:  Tuple     ="""▁"""

# Segments (not really needed)
_UpperCAmelCase			:  str     =0
_UpperCAmelCase			:  List[str]     =1
_UpperCAmelCase			:  int     =2
_UpperCAmelCase			:  Any     =3
_UpperCAmelCase			:  List[Any]     =4







class 				snake_case__(							UpperCAmelCase__							):







						'''simple docstring'''




						SCREAMING_SNAKE_CASE__      :  int					=							VOCAB_FILES_NAMES
						SCREAMING_SNAKE_CASE__      :  Dict					=							PRETRAINED_VOCAB_FILES_MAP
						SCREAMING_SNAKE_CASE__      :  Optional[Any]					=							PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
						SCREAMING_SNAKE_CASE__      :  Any					=							"""left"""
						SCREAMING_SNAKE_CASE__      :  List[Any]					=							XLNetTokenizer




						def __init__(				self   ,						__lowercase=None   ,						__lowercase=None   ,						__lowercase=False   ,						__lowercase=True   ,						__lowercase=False   ,						__lowercase="<s>"   ,						__lowercase="</s>"   ,						__lowercase="<unk>"   ,						__lowercase="<sep>"   ,						__lowercase="<pad>"   ,						__lowercase="<cls>"   ,						__lowercase="<mask>"   ,						__lowercase=["<eop>", "<eod>"]   ,						**__lowercase   ,						)					->    List[Any]:
										# Mask token behave like a normal word, i.e. include the space before it
										lowerCAmelCase_ :      Any    				=				AddedToken(__lowercase   ,						lstrip=__lowercase   ,						rstrip=__lowercase							) if isinstance(__lowercase   ,						__lowercase							) else mask_token

										super().__init__(
										    vocab_file=__lowercase   ,						tokenizer_file=__lowercase   ,						do_lower_case=__lowercase   ,						remove_space=__lowercase   ,						keep_accents=__lowercase   ,						bos_token=__lowercase   ,						eos_token=__lowercase   ,						unk_token=__lowercase   ,						sep_token=__lowercase   ,						pad_token=__lowercase   ,						cls_token=__lowercase   ,						mask_token=__lowercase   ,						additional_special_tokens=__lowercase   ,						**__lowercase   ,						)

										lowerCAmelCase_ :      List[Any]    				=				3
										lowerCAmelCase_ :      Dict    				=				do_lower_case
										lowerCAmelCase_ :      Dict    				=				remove_space
										lowerCAmelCase_ :      List[str]    				=				keep_accents
										lowerCAmelCase_ :      List[str]    				=				vocab_file
										lowerCAmelCase_ :      str    				=				False if not self.vocab_file else True




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




						def 						lowercase_ (				self   ,						__lowercase   ,						__lowercase = None							)					->    List[int]:
										lowerCAmelCase_ :      Optional[Any]    				=				[self.sep_token_id]
										lowerCAmelCase_ :      List[Any]    				=				[2]

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




						def 						lowercase_ (				self   ,						__lowercase   ,						__lowercase = None							)					->    Tuple[str]:
										if not self.can_save_slow_tokenizer:
														raise ValueError(
														    '''Your fast tokenizer does not have the necessary information to save the vocabulary for a slow '''
														    '''tokenizer.'''							)

										if not os.path.isdir(__lowercase							):
														logger.error(f"""Vocabulary path ({save_directory}) should be a directory"""							)
														return
										lowerCAmelCase_ :      str    				=				os.path.join(
										    __lowercase   ,						(filename_prefix + '''-''' if filename_prefix else '''''') + VOCAB_FILES_NAMES['''vocab_file''']							)

										if os.path.abspath(self.vocab_file							) != os.path.abspath(__lowercase							):
														copyfile(self.vocab_file   ,						__lowercase							)

										return (out_vocab_file,)