


'''simple docstring'''






import json
import os
import unittest

from transformers.models.ctrl.tokenization_ctrl import VOCAB_FILES_NAMES, CTRLTokenizer

from ...test_tokenization_common import TokenizerTesterMixin






class  __magic_name__							(		lowerCAmelCase ,unittest.TestCase    ):
       UpperCAmelCase										=CTRLTokenizer
       UpperCAmelCase										=False
       UpperCAmelCase										=False






       def       lowerCAmelCase		(      self)						->  Union[str, Any]:




          '''simple docstring'''
          super().setUp()

          # Adapted from Sennrich et al. 2015 and https://github.com/rsennrich/subword-nmt
          _UpperCAmelCase       :       str							   =['adapt', 're@@', 'a@@', 'apt', 'c@@', 't', '<unk>']
          _UpperCAmelCase       :       Any							   =dict(zip(snake_case  ,							range(len(snake_case))))
          _UpperCAmelCase       :       Optional[int]							   =['#version: 0.2', 'a p', 'ap t</w>', 'r e', 'a d', 'ad apt</w>', '']
          _UpperCAmelCase       :       List[str]							   ={'unk_token': '<unk>'}

          _UpperCAmelCase       :       Tuple							   =os.path.join(self.tmpdirname  ,							VOCAB_FILES_NAMES['vocab_file'])
          _UpperCAmelCase       :       Any							   =os.path.join(self.tmpdirname  ,							VOCAB_FILES_NAMES['merges_file'])
          with open(self.vocab_file  ,							'w'  ,							encoding='utf-8') as fp:
             fp.write(json.dumps(snake_case) + '\n')
          with open(self.merges_file  ,							'w'  ,							encoding='utf-8') as fp:
             fp.write('\n'.join(snake_case))






       def       lowerCAmelCase		(      self  ,							**snake_case)						->  int:




          '''simple docstring'''
          kwargs.update(self.special_tokens_map)
          return CTRLTokenizer.from_pretrained(self.tmpdirname  ,							**snake_case)






       def       lowerCAmelCase		(      self  ,							snake_case)						->  Optional[Any]:




          '''simple docstring'''
          _UpperCAmelCase       :       Any							   ='adapt react readapt apt'
          _UpperCAmelCase       :       Optional[Any]							   ='adapt react readapt apt'
          return input_text, output_text






       def       lowerCAmelCase		(      self)						->  Optional[int]:




          '''simple docstring'''
          _UpperCAmelCase       :       Union[str, Any]							   =CTRLTokenizer(self.vocab_file  ,							self.merges_file  ,							**self.special_tokens_map)
          _UpperCAmelCase       :       Any							   ='adapt react readapt apt'
          _UpperCAmelCase       :       Dict							   ='adapt re@@ a@@ c@@ t re@@ adapt apt'.split()
          _UpperCAmelCase       :       Union[str, Any]							   =tokenizer.tokenize(snake_case)
          self.assertListEqual(snake_case  ,							snake_case)

          _UpperCAmelCase       :       int							   =tokens + [tokenizer.unk_token]

          _UpperCAmelCase       :       Any							   =[0, 1, 2, 4, 5, 1, 0, 3, 6]
          self.assertListEqual(tokenizer.convert_tokens_to_ids(snake_case)  ,							snake_case)





'''simple docstring'''






from string import ascii_uppercase

lowercase							={str(ord(c) - 55): c for c in ascii_uppercase}





def lowerCamelCase__      (						__lowerCamelCase	:							int	,   __lowerCamelCase	:							int							):







   '''simple docstring'''




   if isinstance(__lowerCamelCase	,   __lowerCamelCase							):
      raise TypeError('int() can\'t convert non-string with explicit base'							)
   if num < 0:
      raise ValueError('parameter must be positive int'							)
   if isinstance(__lowerCamelCase	,   __lowerCamelCase							):
      raise TypeError('\'str\' object cannot be interpreted as an integer'							)
   if isinstance(__lowerCamelCase	,   __lowerCamelCase							):
      raise TypeError('\'float\' object cannot be interpreted as an integer'							)
   if base in (0, 1):
      raise ValueError('base must be >= 2'							)
   if base > 3_6:
      raise ValueError('base must be <= 36'							)
   _UpperCAmelCase       :       Union[str, Any]							   =''
   _UpperCAmelCase       :       Optional[int]							   =0
   _UpperCAmelCase       :       str							   =0
   while div != 1:
      _UpperCAmelCase   ,	_UpperCAmelCase       :       int							   =divmod(__lowerCamelCase	,   __lowerCamelCase							)
      if base >= 1_1 and 9 < mod < 3_6:
         _UpperCAmelCase       :       str							   =ALPHABET_VALUES[str(__lowerCamelCase							)]
      else:
         _UpperCAmelCase       :       Any							   =str(__lowerCamelCase							)
      new_value += actual_value
      _UpperCAmelCase       :       Union[str, Any]							   =num // base
      _UpperCAmelCase       :       Dict							   =div
      if div == 0:
         return str(new_value[::-1]							)
      elif div == 1:
         new_value += str(__lowerCamelCase							)
         return str(new_value[::-1]							)

   return new_value[::-1]


if __name__ == "__main__":
 import doctest

 doctest.testmod()

 for base in range(2, 37):
  for num in range(1000):
   assert int(decimal_to_any(num, base), base) == num, (
       num,
       base,
       decimal_to_any(num, base),
       int(decimal_to_any(num, base), base),
   )

