






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:
      __UpperCAmelCase      				=							None

__UpperCAmelCase      				=							logging.get_logger(__name__)

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

__UpperCAmelCase      				=							{
    "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"
        ),
    }
}

__UpperCAmelCase      				=							{
    "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,
}

__UpperCAmelCase      				=							{
    "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 					a_(						lowercase__					):



     """simple docstring"""



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





     def __init__(						self			:					Union[str, Any]       ,       lowerCAmelCase__			:					List[Any]=None       ,       lowerCAmelCase__			:					Any=None       ,       lowerCAmelCase__			:					Union[str, Any]=False       ,       lowerCAmelCase__			:					List[str]=False       ,       lowerCAmelCase__			:					Dict="[CLS]"       ,       lowerCAmelCase__			:					Union[str, Any]="[SEP]"       ,       lowerCAmelCase__			:					Union[str, Any]="[UNK]"       ,       lowerCAmelCase__			:					Tuple="[SEP]"       ,       lowerCAmelCase__			:					Optional[int]="[PAD]"       ,       lowerCAmelCase__			:					List[Any]="[CLS]"       ,       lowerCAmelCase__			:					Optional[Any]="[MASK]"       ,       **lowerCAmelCase__			:					str       ,       )    ->					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__       ,       )

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





     def   __UpperCamelCase		(						self			:					Tuple       ,       lowerCAmelCase__			:					Optional[int]       ,       lowerCAmelCase__			:					Any=None)    ->					Any:

      """simple docstring"""

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





     def   __UpperCamelCase		(						self			:					Optional[int]       ,       lowerCAmelCase__			:					Dict       ,       lowerCAmelCase__			:					Tuple=None       ,       lowerCAmelCase__			:					List[str]=False)    ->					List[Any]:

      """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			:					Dict       ,       lowerCAmelCase__			:					List[str]       ,       lowerCAmelCase__			:					Optional[Any]=None)    ->					List[str]:

      """simple docstring"""
      SCREAMING_SNAKE_CASE							  =						[self.sep_token_id]
      SCREAMING_SNAKE_CASE							  =						[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			:					Dict       ,       lowerCAmelCase__			:					str       ,       lowerCAmelCase__			:					Optional[str] = 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
      SCREAMING_SNAKE_CASE							  =						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,)












from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


__UpperCAmelCase      				=							{"configuration_visual_bert": ["VISUAL_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP", "VisualBertConfig"]}

try:
      if not is_torch_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      __UpperCAmelCase      				=							[
          "VISUAL_BERT_PRETRAINED_MODEL_ARCHIVE_LIST",
          "VisualBertForMultipleChoice",
          "VisualBertForPreTraining",
          "VisualBertForQuestionAnswering",
          "VisualBertForRegionToPhraseAlignment",
          "VisualBertForVisualReasoning",
          "VisualBertLayer",
          "VisualBertModel",
          "VisualBertPreTrainedModel",
      ]


if TYPE_CHECKING:
      from .configuration_visual_bert import VISUAL_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP, VisualBertConfig

      try:
            if not is_torch_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .modeling_visual_bert import (
                VISUAL_BERT_PRETRAINED_MODEL_ARCHIVE_LIST,
                VisualBertForMultipleChoice,
                VisualBertForPreTraining,
                VisualBertForQuestionAnswering,
                VisualBertForRegionToPhraseAlignment,
                VisualBertForVisualReasoning,
                VisualBertLayer,
                VisualBertModel,
                VisualBertPreTrainedModel,
            )


else:
      import sys

      __UpperCAmelCase      				=							_LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)




