
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:
							lowercase__							:							str													=     None

lowercase__							:							str													=     logging.get_logger(__name__)

lowercase__							:							int													=     {"vocab_file": "spm.model", "tokenizer_file": "tokenizer.json"}

lowercase__							:							Union[str, Any]													=     {
    "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"
        ),
    }
}

lowercase__							:							str													=     {
    "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,
}

lowercase__							:							int													=     {
    "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     SCREAMING_SNAKE_CASE__      (							_UpperCAmelCase      ):

							"""simple docstring"""






							_snake_case       						=					VOCAB_FILES_NAMES
							_snake_case       						=					PRETRAINED_VOCAB_FILES_MAP
							_snake_case       						=					PRETRAINED_INIT_CONFIGURATION
							_snake_case       						=					PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
							_snake_case       						=					DebertaVaTokenizer



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





													'''simple docstring'''






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

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



							def       A__						(					self       ,		SCREAMING_SNAKE_CASE_       ,		SCREAMING_SNAKE_CASE_=None     )->				List[Any]:





													'''simple docstring'''






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



							def       A__						(					self       ,		SCREAMING_SNAKE_CASE_       ,		SCREAMING_SNAKE_CASE_=None       ,		SCREAMING_SNAKE_CASE_=False     )->				Dict:





													'''simple docstring'''






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

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



							def       A__						(					self       ,		SCREAMING_SNAKE_CASE_       ,		SCREAMING_SNAKE_CASE_=None     )->				Union[str, Any]:





													'''simple docstring'''






													__UpperCamelCase       					=     [self.sep_token_id]
													__UpperCamelCase       					=     [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       A__						(					self       ,		SCREAMING_SNAKE_CASE_       ,		SCREAMING_SNAKE_CASE_ = None     )->				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(lowercase__     ):
																			logger.error(F"Vocabulary path ({save_directory}) should be a directory"     )
																			return
													__UpperCamelCase       					=     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,)






import torch

from transformers import PreTrainedModel

from .custom_configuration import CustomConfig, NoSuperInitConfig






class     SCREAMING_SNAKE_CASE__      (							SCREAMING_SNAKE_CASE_      ):

							"""simple docstring"""






							_snake_case       						=					CustomConfig



							def __init__(					self       ,		SCREAMING_SNAKE_CASE_     )->				Tuple:





													'''simple docstring'''






													super().__init__(SCREAMING_SNAKE_CASE_     )
													__UpperCamelCase       					=     torch.nn.Linear(config.hidden_size       ,		config.hidden_size     )



							def       A__						(					self       ,		SCREAMING_SNAKE_CASE_     )->				List[str]:





													'''simple docstring'''






													return self.linear(SCREAMING_SNAKE_CASE_     )



							def       A__						(					self       ,		SCREAMING_SNAKE_CASE_     )->				Any:





													'''simple docstring'''






													pass






class     SCREAMING_SNAKE_CASE__      (							SCREAMING_SNAKE_CASE_      ):

							"""simple docstring"""






							_snake_case       						=					NoSuperInitConfig



							def __init__(					self       ,		SCREAMING_SNAKE_CASE_     )->				Tuple:





													'''simple docstring'''






													super().__init__(SCREAMING_SNAKE_CASE_     )
													__UpperCamelCase       					=     torch.nn.Linear(config.attribute       ,		config.attribute     )



							def       A__						(					self       ,		SCREAMING_SNAKE_CASE_     )->				List[str]:





													'''simple docstring'''






													return self.linear(SCREAMING_SNAKE_CASE_     )



							def       A__						(					self       ,		SCREAMING_SNAKE_CASE_     )->				Union[str, Any]:





													'''simple docstring'''






													pass




