





import json
from typing import List, Optional, Tuple

from tokenizers import normalizers

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_splinter import SplinterTokenizer


__lowerCAmelCase 	=      logging.get_logger(__name__)

__lowerCAmelCase 	=      {"vocab_file": "vocab.txt"}

__lowerCAmelCase 	=      {
    "vocab_file": {
        "tau/splinter-base": "https://huggingface.co/tau/splinter-base/resolve/main/vocab.txt",
        "tau/splinter-base-qass": "https://huggingface.co/tau/splinter-base-qass/resolve/main/vocab.txt",
        "tau/splinter-large": "https://huggingface.co/tau/splinter-large/resolve/main/vocab.txt",
        "tau/splinter-large-qass": "https://huggingface.co/tau/splinter-large-qass/resolve/main/vocab.txt",
    }
}

__lowerCAmelCase 	=      {
    "tau/splinter-base": 512,
    "tau/splinter-base-qass": 512,
    "tau/splinter-large": 512,
    "tau/splinter-large-qass": 512,
}

__lowerCAmelCase 	=      {
    "tau/splinter-base": {"do_lower_case": False},
    "tau/splinter-base-qass": {"do_lower_case": False},
    "tau/splinter-large": {"do_lower_case": False},
    "tau/splinter-large-qass": {"do_lower_case": False},
}




class 	_UpperCAmelCase						( _lowercase       ):
					__A        = VOCAB_FILES_NAMES
					__A        = PRETRAINED_VOCAB_FILES_MAP
					__A        = PRETRAINED_INIT_CONFIGURATION
					__A        = PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
					__A        = SplinterTokenizer




					def __init__(    self     ,   __lowerCAmelCase=None     ,   __lowerCAmelCase=None     ,   __lowerCAmelCase=True     ,   __lowerCAmelCase="[UNK]"     ,   __lowerCAmelCase="[SEP]"     ,   __lowerCAmelCase="[PAD]"     ,   __lowerCAmelCase="[CLS]"     ,   __lowerCAmelCase="[MASK]"     ,   __lowerCAmelCase="[QUESTION]"     ,   __lowerCAmelCase=True     ,   __lowerCAmelCase=None     ,   **__lowerCAmelCase     ,   )    ->	Any:
							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     ,   additional_special_tokens=(question_token,)     ,   **__lowerCAmelCase     ,   )

							UpperCamelCase__								=						json.loads(self.backend_tokenizer.normalizer.__getstate__()							)
							if (
							    pre_tok_state.get("""lowercase"""     ,   __lowerCAmelCase							) != do_lower_case
							    or pre_tok_state.get("""strip_accents"""     ,   __lowerCAmelCase							) != strip_accents
							):
									UpperCamelCase__								=						getattr(__lowerCAmelCase     ,   pre_tok_state.pop("""type"""							)							)
									UpperCamelCase__								=						do_lower_case
									UpperCamelCase__								=						strip_accents
									UpperCamelCase__								=						pre_tok_class(**__lowerCAmelCase							)

							UpperCamelCase__								=						do_lower_case




					@property
					def 						snake_case_		(    self							)    ->	Tuple:
							return self.convert_tokens_to_ids(self.question_token							)




					def 						snake_case_		(    self     ,   __lowerCAmelCase     ,   __lowerCAmelCase = None							)    ->	List[int]:
							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]
							UpperCamelCase__								=						[self.question_token_id] + [self.convert_tokens_to_ids("""."""							)]
							if self.padding_side == "right":
									# Input is question-then-context
									return cls + token_ids_a + question_suffix + sep + token_ids_a + sep
							else:
									# Input is context-then-question
									return cls + token_ids_a + sep + token_ids_a + question_suffix + sep




					def 						snake_case_		(    self     ,   __lowerCAmelCase     ,   __lowerCAmelCase = None							)    ->	List[int]:
							UpperCamelCase__								=						[self.sep_token_id]
							UpperCamelCase__								=						[self.cls_token_id]
							UpperCamelCase__								=						[self.question_token_id] + [self.convert_tokens_to_ids("""."""							)]
							if token_ids_a is None:
									return len(cls + token_ids_a + sep							) * [0]

							if self.padding_side == "right":
									# Input is question-then-context
									return len(cls + token_ids_a + question_suffix + sep							) * [0] + len(token_ids_a + sep							) * [1]
							else:
									# Input is context-then-question
									return len(cls + token_ids_a + sep							) * [0] + len(token_ids_a + question_suffix + sep							) * [1]




					def 						snake_case_		(    self     ,   __lowerCAmelCase     ,   __lowerCAmelCase = None							)    ->	Tuple[str]:
							UpperCamelCase__								=						self._tokenizer.model.save(__lowerCAmelCase     ,   name=__lowerCAmelCase							)
							return tuple(__lowerCAmelCase							)












from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


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

try:
				if not is_torch_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				__lowerCAmelCase 	=      [
				    "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

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





