"""simple docstring"""
import inspect
import json
import os
import tempfile
import unittest

from transformers.models.speech_to_text_a import SpeechaTextaTokenizer
from transformers.models.speech_to_text_a.tokenization_speech_to_text_a import VOCAB_FILES_NAMES

from ...test_tokenization_common import TokenizerTesterMixin




class   __snake_case			(	__lowerCAmelCase			, unittest.TestCase							):
      a__								=						SpeechaTextaTokenizer
      a__								=						False



      def     lowerCamelCase_  (		self)      ->     Dict:





        '''simple docstring'''





        super().setUp()

        a__:	Tuple     				=      '<s> <pad> </s> <unk> here@@ a couple of@@ words for the he@@ re@@ vocab'.split(' ')
        a__:	Any     				=      ['he re</w> 123', 'here a 1456']
        a__:	Any     				=      dict(zip(lowercase       ,     range(len(lowercase))))

        a__:	List[str]     				=      {'pad_token': '<pad>', 'unk_token': '<unk>', 'bos_token': '<s>', 'eos_token': '</s>'}

        a__:	str     				=      tempfile.mkdtemp()
        a__:	List[Any]     				=      os.path.join(self.tmpdirname       ,     VOCAB_FILES_NAMES['vocab_file'])
        a__:	Optional[int]     				=      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(lowercase) + '\n')

        with open(self.merges_file       ,     'w') as fp:
          fp.write('\n'.join(lowercase))



      def     lowerCamelCase_  (		self)      ->     str:





        '''simple docstring'''





        a__:	Any     				=      list(self.get_tokenizer().get_vocab().keys())

        self.assertEqual(vocab_keys[0]       ,     '<s>')
        self.assertEqual(vocab_keys[1]       ,     '<pad>')
        self.assertEqual(vocab_keys[-1]       ,     'vocab')
        self.assertEqual(len(lowercase)       ,     14)



      def     lowerCamelCase_  (		self)      ->     Any:





        '''simple docstring'''





        self.assertEqual(self.get_tokenizer().vocab_size       ,     14)



      def     lowerCamelCase_  (		self)      ->     str:





        '''simple docstring'''





        a__:	Any     				=      SpeechaTextaTokenizer.from_pretrained(self.tmpdirname)

        # make sure @@ is correctly concatenated
        a__:	Dict     				=      [4, 6, 8, 7, 10]  # ["here@@", "couple", "words", "of@@", "the"]
        a__:	List[Any]     				=      tokenizer.decode(lowercase)

        self.assertTrue(output_string == 'herecouple words ofthe')



      def     lowerCamelCase_  (		self)      ->     int:





        '''simple docstring'''





        a__:	Optional[int]     				=      SpeechaTextaTokenizer.from_pretrained(self.tmpdirname)

        with tempfile.TemporaryDirectory() as tmp_dirname:
          tokenizer.save_pretrained(lowercase)
          os.remove(os.path.join(lowercase       ,     'merges.txt'))

          # load tokenizer without merges file should not throw an error
          a__:	Union[str, Any]     				=      SpeechaTextaTokenizer.from_pretrained(lowercase)

        with tempfile.TemporaryDirectory() as tmp_dirname:
          # save tokenizer and load again
          tokenizer.save_pretrained(lowercase)
          a__:	Tuple     				=      SpeechaTextaTokenizer.from_pretrained(lowercase)

        self.assertIsNotNone(lowercase)



      def     lowerCamelCase_  (		self)      ->     List[Any]:





        '''simple docstring'''





        if not self.test_slow_tokenizer:
          return

        a__:	List[Any]     				=      inspect.signature(self.tokenizer_class.__init__)
        a__:	Optional[int]     				=      self.get_tokenizer()

        for parameter_name, parameter in signature.parameters.items():
          if parameter.default != inspect.Parameter.empty and parameter_name != "merges_file":
            self.assertIn(lowercase       ,     tokenizer.init_kwargs)



"""simple docstring"""
def 		__a  (      _SCREAMING_SNAKE_CASE = 100						,	_SCREAMING_SNAKE_CASE = 100  )      ->int:
  return max(
      sum(int(_SCREAMING_SNAKE_CASE  ) for x in str(base**power  )  )
      for base in range(_SCREAMING_SNAKE_CASE  )
      for power in range(_SCREAMING_SNAKE_CASE  )  )


# Tests
if __name__ == "__main__":
 import doctest

 doctest.testmod()


