import math
from timeit import timeit
def 	UpperCamelCase			(     snake_case__ :					int			)			->  int:
   UpperCamelCase					:						Tuple					=			0
   UpperCamelCase					:						Union[str, Any]					=			abs(snake_case__			)
   while True:
      UpperCamelCase					:						Dict					=			n // 10
      digits += 1
      if n == 0:
         break
   return digits
def 	UpperCamelCase			(     snake_case__ :					int			)			->  int:
   return 1 if n == 0 else math.floor(math.log(abs(snake_case__			) ,  10			) + 1			)
def 	UpperCamelCase			(     snake_case__ :					int			)			->  int:
   return len(str(abs(snake_case__			)			)			)
def 	UpperCamelCase			(     )			->  None:
   from collections.abc import Callable

   def benchmark_a_function(snake_case__ :					Callable ,  snake_case__ :					int			) -> None:
      UpperCamelCase					:						Any					=			F"""{func.__name__}({value})"""
      UpperCamelCase					:						List[str]					=			timeit(F"""__main__.{call}""" ,  setup='import __main__'			)
      print(F"""{call}: {func(snake_case__			)} -- {timing} seconds"""			)

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


if __name__ == "__main__":
    import doctest

    doctest.testmod()
    benchmark()








from typing import Optional, Tuple

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_openai import OpenAIGPTTokenizer


__UpperCAmelCase      = logging.get_logger(__name__)

__UpperCAmelCase      = {'''vocab_file''': '''vocab.json''', '''merges_file''': '''merges.txt''', '''tokenizer_file''': '''tokenizer.json'''}

__UpperCAmelCase      = {
    '''vocab_file''': {'''openai-gpt''': '''https://huggingface.co/openai-gpt/resolve/main/vocab.json'''},
    '''merges_file''': {'''openai-gpt''': '''https://huggingface.co/openai-gpt/resolve/main/merges.txt'''},
    '''tokenizer_file''': {'''openai-gpt''': '''https://huggingface.co/openai-gpt/resolve/main/tokenizer.json'''},
}

__UpperCAmelCase      = {
    '''openai-gpt''': 512,
}



class        lowerCAmelCase_	(						a__							):
       UpperCAmelCase__       :      Union[str, Any]       =						VOCAB_FILES_NAMES
       UpperCAmelCase__       :      int       =						PRETRAINED_VOCAB_FILES_MAP
       UpperCAmelCase__       :      Optional[int]       =						PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
       UpperCAmelCase__       :      Optional[int]       =						["input_ids", "attention_mask"]
       UpperCAmelCase__       :      Tuple       =						OpenAIGPTTokenizer
       def __init__(    self,    SCREAMING_SNAKE_CASE_=None,    SCREAMING_SNAKE_CASE_=None,    SCREAMING_SNAKE_CASE_=None,    SCREAMING_SNAKE_CASE_="<unk>",    **SCREAMING_SNAKE_CASE_ )  ->	List[str]:
          super().__init__(SCREAMING_SNAKE_CASE_,    SCREAMING_SNAKE_CASE_,    tokenizer_file=SCREAMING_SNAKE_CASE_,    unk_token=SCREAMING_SNAKE_CASE_,    **SCREAMING_SNAKE_CASE_ )
       @property
       def       snake_case_ (    self )  ->	Dict:
          return True






       def       snake_case_ (    self,    SCREAMING_SNAKE_CASE_,    SCREAMING_SNAKE_CASE_ = None )  ->	Tuple[str]:
          UpperCamelCase					:						List[Any]					=			self._tokenizer.model.save(SCREAMING_SNAKE_CASE_,    name=SCREAMING_SNAKE_CASE_ )
          return tuple(SCREAMING_SNAKE_CASE_ )



