"""simple docstring"""


import copy
import random

from transformers import CLIPTokenizer


class        a				(		_A   ):


    def __init__(					self	:  List[str]   ,				*__lowerCAmelCase	:  List[str]   ,				**__lowerCAmelCase	:  Optional[int]					):
      super().__init__(*UpperCamelCase__   ,				**UpperCamelCase__					)
      _UpperCAmelCase						 =      {}


    def      lowerCAmelCase_  (					self	:  Optional[Any]   ,				__lowerCAmelCase	:  Optional[Any]   ,				*__lowerCAmelCase	:  Union[str, Any]   ,				**__lowerCAmelCase	:  Optional[int]					):
      _UpperCAmelCase						 =      super().add_tokens(UpperCamelCase__   ,				*UpperCamelCase__   ,				**UpperCamelCase__					)
      if num_added_tokens == 0:
        raise ValueError(
            f'''The tokenizer already contains the token {placeholder_token}. Please pass a different'''
            """ `placeholder_token` that is not already in the tokenizer."""					)


    def      lowerCAmelCase_  (					self	:  Any   ,				__lowerCAmelCase	:  Union[str, Any]   ,				*__lowerCAmelCase	:  Optional[Any]   ,				__lowerCAmelCase	:  str=1   ,				**__lowerCAmelCase	:  Dict					):
      _UpperCAmelCase						 =      []
      if num_vec_per_token == 1:
        self.try_adding_tokens(UpperCamelCase__   ,				*UpperCamelCase__   ,				**UpperCamelCase__					)
        output.append(UpperCamelCase__					)
      else:
        _UpperCAmelCase						 =      []
        for i in range(UpperCamelCase__					):
          _UpperCAmelCase						 =      placeholder_token + f'''_{i}'''
          self.try_adding_tokens(UpperCamelCase__   ,				*UpperCamelCase__   ,				**UpperCamelCase__					)
          output.append(UpperCamelCase__					)
          # handle cases where there is a new placeholder token that contains the current placeholder token but is larger
      for token in self.token_map:
        if token in placeholder_token:
          raise ValueError(
              f'''The tokenizer already has placeholder token {token} that can get confused with'''
              f''' {placeholder_token}keep placeholder tokens independent'''					)
      _UpperCAmelCase						 =      output


    def      lowerCAmelCase_  (					self	:  Any   ,				__lowerCAmelCase	:  Union[str, Any]   ,				__lowerCAmelCase	:  List[str]=False   ,				__lowerCAmelCase	:  List[Any]=1.0					):






      if isinstance(UpperCamelCase__   ,				UpperCamelCase__					):
        _UpperCAmelCase						 =      []
        for i in range(len(UpperCamelCase__					)					):
          output.append(self.replace_placeholder_tokens_in_text(text[i]   ,				vector_shuffle=UpperCamelCase__					)					)
        return output
      for placeholder_token in self.token_map:
        if placeholder_token in text:
          _UpperCAmelCase						 =      self.token_map[placeholder_token]
          _UpperCAmelCase						 =      tokens[: 1 + int(len(UpperCamelCase__					) * prop_tokens_to_load					)]
          if vector_shuffle:
            _UpperCAmelCase						 =      copy.copy(UpperCamelCase__					)
            random.shuffle(UpperCamelCase__					)
          _UpperCAmelCase						 =      text.replace(UpperCamelCase__   ,				""" """.join(UpperCamelCase__					)					)
      return text


    def __call__(					self	:  Optional[int]   ,				__lowerCAmelCase	:  List[str]   ,				*__lowerCAmelCase	:  Dict   ,				__lowerCAmelCase	:  List[Any]=False   ,				__lowerCAmelCase	:  str=1.0   ,				**__lowerCAmelCase	:  str					):
      return super().__call__(
          self.replace_placeholder_tokens_in_text(
              UpperCamelCase__   ,				vector_shuffle=UpperCamelCase__   ,				prop_tokens_to_load=UpperCamelCase__					)   ,				*UpperCamelCase__   ,				**UpperCamelCase__   ,				)


    def      lowerCAmelCase_  (					self	:  int   ,				__lowerCAmelCase	:  List[str]   ,				*__lowerCAmelCase	:  List[str]   ,				__lowerCAmelCase	:  Optional[int]=False   ,				__lowerCAmelCase	:  Union[str, Any]=1.0   ,				**__lowerCAmelCase	:  Optional[Any]					):
      return super().encode(
          self.replace_placeholder_tokens_in_text(
              UpperCamelCase__   ,				vector_shuffle=UpperCamelCase__   ,				prop_tokens_to_load=UpperCamelCase__					)   ,				*UpperCamelCase__   ,				**UpperCamelCase__   ,				)

"""simple docstring"""


def     __UpperCAmelCase					(			lowercase		):







  """simple docstring"""
  _UpperCAmelCase						 =      abs(lowercase		)
  _UpperCAmelCase						 =      0
  while n > 0:
    res += n % 10
    n //= 10
  return res






def     __UpperCAmelCase					(			lowercase		):







  """simple docstring"""
  _UpperCAmelCase						 =      abs(lowercase		)
  return n if n < 10 else n % 10 + sum_of_digits(n // 10		)






def     __UpperCAmelCase					(			lowercase		):







  """simple docstring"""
  return sum(int(lowercase		) for c in str(abs(lowercase		)		)		)






def     __UpperCAmelCase					(			):







  """simple docstring"""
  from collections.abc import Callable
  from timeit import timeit

  def benchmark_a_function(lowercase   ,lowercase		) -> None:
    _UpperCAmelCase						 =      f'''{func.__name__}({value})'''
    _UpperCAmelCase						 =      timeit(f'''__main__.{call}'''   ,setup="""import __main__"""		)
    print(f'''{call:56} = {func(lowercase		)} -- {timing:.4f} seconds'''		)

  for value in (26_21_44, 11_25_89_99_06_84_26_24, 1_26_76_50_60_02_28_22_94_01_49_67_03_20_53_76):
    for func in (sum_of_digits, sum_of_digits_recursion, sum_of_digits_compact):
      benchmark_a_function(lowercase   ,lowercase		)
    print()


if __name__ == "__main__":
    import doctest

    doctest.testmod()
    benchmark()
