






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


__UpperCAmelCase      				=							logging.get_logger(__name__)

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

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

__UpperCAmelCase      				=							{
    "tau/splinter-base": 5_1_2,
    "tau/splinter-base-qass": 5_1_2,
    "tau/splinter-large": 5_1_2,
    "tau/splinter-large-qass": 5_1_2,
}

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



     """simple docstring"""



     __snake_case						:							Any       			=VOCAB_FILES_NAMES
     __snake_case						:							Union[str, Any]       			=PRETRAINED_VOCAB_FILES_MAP
     __snake_case						:							List[Any]       			=PRETRAINED_INIT_CONFIGURATION
     __snake_case						:							Any       			=PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
     __snake_case						:							List[Any]       			=SplinterTokenizer





     def __init__(						self			:					Dict       ,       lowerCAmelCase__			:					List[str]=None       ,       lowerCAmelCase__			:					List[Any]=None       ,       lowerCAmelCase__			:					List[Any]=True       ,       lowerCAmelCase__			:					Tuple="[UNK]"       ,       lowerCAmelCase__			:					List[Any]="[SEP]"       ,       lowerCAmelCase__			:					Union[str, Any]="[PAD]"       ,       lowerCAmelCase__			:					Optional[int]="[CLS]"       ,       lowerCAmelCase__			:					Optional[Any]="[MASK]"       ,       lowerCAmelCase__			:					Optional[int]="[QUESTION]"       ,       lowerCAmelCase__			:					Tuple=True       ,       lowerCAmelCase__			:					Union[str, Any]=None       ,       **lowerCAmelCase__			:					List[Any]       ,       )    ->					Tuple:

      """simple docstring"""
      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__       ,       )

      SCREAMING_SNAKE_CASE							  =						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
      ):
       SCREAMING_SNAKE_CASE							  =						getattr(lowerCAmelCase__       ,       pre_tok_state.pop('type'))
       SCREAMING_SNAKE_CASE							  =						do_lower_case
       SCREAMING_SNAKE_CASE							  =						strip_accents
       SCREAMING_SNAKE_CASE							  =						pre_tok_class(**lowerCAmelCase__)

      SCREAMING_SNAKE_CASE							  =						do_lower_case





     @property
     def   __UpperCamelCase		(						self			:					str)    ->					Tuple:

      """simple docstring"""
      return self.convert_tokens_to_ids(self.question_token)





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

      """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]
      SCREAMING_SNAKE_CASE							  =						[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   __UpperCamelCase		(						self			:					List[Any]       ,       lowerCAmelCase__			:					Union[str, Any]       ,       lowerCAmelCase__			:					Union[str, Any] = None)    ->					Any:

      """simple docstring"""
      SCREAMING_SNAKE_CASE							  =						[self.sep_token_id]
      SCREAMING_SNAKE_CASE							  =						[self.cls_token_id]
      SCREAMING_SNAKE_CASE							  =						[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   __UpperCamelCase		(						self			:					Tuple       ,       lowerCAmelCase__			:					int       ,       lowerCAmelCase__			:					Any = None)    ->					str:

      """simple docstring"""
      SCREAMING_SNAKE_CASE							  =						self._tokenizer.model.save(lowerCAmelCase__       ,       name=lowerCAmelCase__)
      return tuple(lowerCAmelCase__)












def 		A_			(		lowercase_	)							->int:







 """simple docstring"""

 if not isinstance(lowercase_					,       lowercase_	):
  SCREAMING_SNAKE_CASE							  =						f'''Input value of [number={number}] must be an integer'''
  raise TypeError(lowercase_	)
 if number < 1:
  raise ValueError('Input must be a positive integer'	)
 return number * (2 * number - 1)


if __name__ == "__main__":
      import doctest

      doctest.testmod()




