


'''simple docstring'''







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


a__    :   Tuple								=			logging.get_logger(__name__)

a__    :   Optional[Any]								=			{'vocab_file': 'vocab.txt'}

a__    :   int								=			{
    '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',
    }
}

a__    :   Dict								=			{
    '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,
}

a__    :   Tuple								=			{
    '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    lowercase_	(       a__  ):
    __UpperCAmelCase       =      VOCAB_FILES_NAMES
    __UpperCAmelCase       =      PRETRAINED_VOCAB_FILES_MAP
    __UpperCAmelCase       =      PRETRAINED_INIT_CONFIGURATION
    __UpperCAmelCase       =      PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
    __UpperCAmelCase       =      SplinterTokenizer


    def __init__(	self    ,   a=None    ,   a=None    ,   a=True    ,   a="[UNK]"    ,   a="[SEP]"    ,   a="[PAD]"    ,   a="[CLS]"    ,   a="[MASK]"    ,   a="[QUESTION]"    ,   a=True    ,   a=None    ,   **a    ,   ):
          super().__init__(
              a    ,   tokenizer_file=a    ,   do_lower_case=a    ,   unk_token=a    ,   sep_token=a    ,   pad_token=a    ,   cls_token=a    ,   mask_token=a    ,   tokenize_chinese_chars=a    ,   strip_accents=a    ,   additional_special_tokens=(question_token,)    ,   **a    ,   )

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

          UpperCamelCase__      =							do_lower_case


    @property
    def   __a				(	self       ):
          return self.convert_tokens_to_ids(self.question_token       )


    def   __a				(	self    ,   a    ,   a = None       ):
          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   __a				(	self    ,   a    ,   a = None       ):
          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   __a				(	self    ,   a    ,   a = None       ):
          UpperCamelCase__      =							self._tokenizer.model.save(a    ,   name=a       )
          return tuple(a       )









'''simple docstring'''







import math
from timeit import timeit







def _UpperCamelCase			(	__A       )				->						int:


      '''simple docstring'''



      UpperCamelCase__      =							0
      UpperCamelCase__      =							abs(__A       )
      while True:
            UpperCamelCase__      =							n // 10
            digits += 1
            if n == 0:
                  break
      return digits







def _UpperCamelCase			(	__A       )				->						int:


      '''simple docstring'''



      return 1 if n == 0 else math.floor(math.log(abs(__A       ) ,     10       ) + 1       )







def _UpperCamelCase			(	__A       )				->						int:


      '''simple docstring'''



      return len(str(abs(__A       )       )       )







def _UpperCamelCase			(	)				->						None:


      '''simple docstring'''



      from collections.abc import Callable

      def benchmark_a_function(__A ,     __A       ) -> None:
            UpperCamelCase__      =							F'''{func.__name__}({value})'''
            UpperCamelCase__      =							timeit(F'''__main__.{call}''' ,     setup="import __main__"       )
            print(F'''{call}: {func(__A       )} -- {timing} seconds'''       )

      for value in (262144, 1125899906842624, 1267650600228229401496703205376):
            for func in (num_digits, num_digits_fast, num_digits_faster):
                  benchmark_a_function(__A ,     __A       )
            print()


if __name__ == "__main__":
  import doctest

  doctest.testmod()
  benchmark()





