





'''simple docstring'''



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

from ...file_utils import is_sentencepiece_available
from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging


if is_sentencepiece_available():
	from .tokenization_deberta_va import DebertaVaTokenizer
else:
	_SCREAMING_SNAKE_CASE    =			None

_SCREAMING_SNAKE_CASE    =			logging.get_logger(__name__)

_SCREAMING_SNAKE_CASE    =			{'''vocab_file''': '''spm.model''', '''tokenizer_file''': '''tokenizer.json'''}

_SCREAMING_SNAKE_CASE    =			{
    '''vocab_file''': {
        '''microsoft/deberta-v2-xlarge''': '''https://huggingface.co/microsoft/deberta-v2-xlarge/resolve/main/spm.model''',
        '''microsoft/deberta-v2-xxlarge''': '''https://huggingface.co/microsoft/deberta-v2-xxlarge/resolve/main/spm.model''',
        '''microsoft/deberta-v2-xlarge-mnli''': (
            '''https://huggingface.co/microsoft/deberta-v2-xlarge-mnli/resolve/main/spm.model'''
        ),
        '''microsoft/deberta-v2-xxlarge-mnli''': (
            '''https://huggingface.co/microsoft/deberta-v2-xxlarge-mnli/resolve/main/spm.model'''
        ),
    }
}

_SCREAMING_SNAKE_CASE    =			{
    '''microsoft/deberta-v2-xlarge''': 5_1_2,
    '''microsoft/deberta-v2-xxlarge''': 5_1_2,
    '''microsoft/deberta-v2-xlarge-mnli''': 5_1_2,
    '''microsoft/deberta-v2-xxlarge-mnli''': 5_1_2,
}

_SCREAMING_SNAKE_CASE    =			{
    '''microsoft/deberta-v2-xlarge''': {'''do_lower_case''': False},
    '''microsoft/deberta-v2-xxlarge''': {'''do_lower_case''': False},
    '''microsoft/deberta-v2-xlarge-mnli''': {'''do_lower_case''': False},
    '''microsoft/deberta-v2-xxlarge-mnli''': {'''do_lower_case''': False},
}






class 							__lowercase				(					lowerCAmelCase__  ):







	'''simple docstring'''

	a			: int      =				VOCAB_FILES_NAMES
	a			: Union[str, Any]      =				PRETRAINED_VOCAB_FILES_MAP
	a			: Optional[int]      =				PRETRAINED_INIT_CONFIGURATION
	a			: str      =				PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
	a			: Any      =				DebertaVaTokenizer


	def __init__(self   ,_lowerCamelCase=None   ,_lowerCamelCase=None   ,_lowerCamelCase=False   ,_lowerCamelCase=False   ,_lowerCamelCase="[CLS]"   ,_lowerCamelCase="[SEP]"   ,_lowerCamelCase="[UNK]"   ,_lowerCamelCase="[SEP]"   ,_lowerCamelCase="[PAD]"   ,_lowerCamelCase="[CLS]"   ,_lowerCamelCase="[MASK]"   ,**_lowerCamelCase   ,)							->							None:







				'''simple docstring'''





				super().__init__(
				    _lowerCamelCase   ,tokenizer_file=_lowerCamelCase   ,do_lower_case=_lowerCamelCase   ,bos_token=_lowerCamelCase   ,eos_token=_lowerCamelCase   ,unk_token=_lowerCamelCase   ,sep_token=_lowerCamelCase   ,pad_token=_lowerCamelCase   ,cls_token=_lowerCamelCase   ,mask_token=_lowerCamelCase   ,split_by_punct=_lowerCamelCase   ,**_lowerCamelCase   ,)

				__lowercase   =							do_lower_case
				__lowercase   =							split_by_punct
				__lowercase   =							vocab_file
				__lowercase   =							False if not self.vocab_file else True


	def   _UpperCAmelCase   (self   ,_lowerCamelCase   ,_lowerCamelCase=None       )							->							str:







				'''simple docstring'''





				if token_ids_a is None:
							return [self.cls_token_id] + token_ids_a + [self.sep_token_id]
				__lowercase   =							[self.cls_token_id]
				__lowercase   =							[self.sep_token_id]
				return cls + token_ids_a + sep + token_ids_a + sep


	def   _UpperCAmelCase   (self   ,_lowerCamelCase   ,_lowerCamelCase=None   ,_lowerCamelCase=False       )							->							int:







				'''simple docstring'''





				if already_has_special_tokens:
							return super().get_special_tokens_mask(
							    token_ids_a=_lowerCamelCase   ,token_ids_a=_lowerCamelCase   ,already_has_special_tokens=_lowerCamelCase       )

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


	def   _UpperCAmelCase   (self   ,_lowerCamelCase   ,_lowerCamelCase=None       )							->							Dict:







				'''simple docstring'''





				__lowercase   =							[self.sep_token_id]
				__lowercase   =							[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   _UpperCAmelCase   (self   ,_lowerCamelCase   ,_lowerCamelCase = None       )							->							Tuple[str]:







				'''simple docstring'''





				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(_lowerCamelCase       ):
							logger.error(f"Vocabulary path ({save_directory}) should be a directory"       )
							return
				__lowercase   =							os.path.join(
				    _lowerCamelCase   ,(filename_prefix + '''-''' if filename_prefix else '''''') + VOCAB_FILES_NAMES['''vocab_file''']       )

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

				return (out_vocab_file,)












'''simple docstring'''



import torch

from transformers import PreTrainedModel

from .custom_configuration import CustomConfig, NoSuperInitConfig






class 							__lowercase				(					lowerCAmelCase__  ):







	'''simple docstring'''

	a			: Union[str, Any]      =				CustomConfig


	def __init__(self   ,_lowerCamelCase       )							->							Tuple:







				'''simple docstring'''





				super().__init__(_lowerCamelCase       )
				__lowercase   =							torch.nn.Linear(config.hidden_size   ,config.hidden_size       )


	def   _UpperCAmelCase   (self   ,_lowerCamelCase       )							->							List[str]:







				'''simple docstring'''





				return self.linear(_lowerCamelCase       )


	def   _UpperCAmelCase   (self   ,_lowerCamelCase       )							->							List[Any]:







				'''simple docstring'''





				pass






class 							__lowercase				(					lowerCAmelCase__  ):







	'''simple docstring'''

	a			: Dict      =				NoSuperInitConfig


	def __init__(self   ,_lowerCamelCase       )							->							str:







				'''simple docstring'''





				super().__init__(_lowerCamelCase       )
				__lowercase   =							torch.nn.Linear(config.attribute   ,config.attribute       )


	def   _UpperCAmelCase   (self   ,_lowerCamelCase       )							->							List[str]:







				'''simple docstring'''





				return self.linear(_lowerCamelCase       )


	def   _UpperCAmelCase   (self   ,_lowerCamelCase       )							->							Tuple:







				'''simple docstring'''





				pass





