


import json
import os
import unittest

from transformers import MgpstrTokenizer
from transformers.models.mgp_str.tokenization_mgp_str import VOCAB_FILES_NAMES
from transformers.testing_utils import require_tokenizers

from ...test_tokenization_common import TokenizerTesterMixin






@require_tokenizers
class    UpperCAmelCase__	( __SCREAMING_SNAKE_CASE       ,  unittest.TestCase		):



    """simple docstring"""






    UpperCAmelCase__						:		List[str]              =  MgpstrTokenizer
    UpperCAmelCase__						:		List[str]              =  False
    UpperCAmelCase__						:		Optional[Any]              =  {}
    UpperCAmelCase__						:		List[str]              =  False






    def _a (      self   )  ->	Tuple:
         super().setUp()

         # fmt: off
         __UpperCamelCase   							=['''[GO]''', '''[s]''', '''0''', '''1''', '''2''', '''3''', '''4''', '''5''', '''6''', '''7''', '''8''', '''9''', '''a''', '''b''', '''c''', '''d''', '''e''', '''f''', '''g''', '''h''', '''i''', '''j''', '''k''', '''l''', '''m''', '''n''', '''o''', '''p''', '''q''', '''r''', '''s''', '''t''', '''u''', '''v''', '''w''', '''x''', '''y''', '''z''']
         # fmt: on
         __UpperCamelCase   							=dict(zip(UpperCamelCase__ ,       range(len(UpperCamelCase__   )   )   )   )

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






    def _a (      self ,       **A_   )  ->	Any:
         return MgpstrTokenizer.from_pretrained(self.tmpdirname ,       **UpperCamelCase__   )






    def _a (      self ,       A_   )  ->	Tuple:
         __UpperCamelCase   							='''tester'''
         __UpperCamelCase   							='''tester'''
         return input_text, output_text






    @unittest.skip('MGP-STR always lower cases letters.'   )
    def _a (      self   )  ->	Dict:
         pass






    def _a (      self   )  ->	Optional[Any]:
         __UpperCamelCase   							=self.get_tokenizers(do_lower_case=UpperCamelCase__   )
         for tokenizer in tokenizers:
              with self.subTest(f'{tokenizer.__class__.__name__}'   ):
                   __UpperCamelCase   							='''[SPECIAL_TOKEN]'''

                   tokenizer.add_special_tokens({'cls_token': special_token}   )
                   __UpperCamelCase   							=tokenizer.encode([special_token] ,       add_special_tokens=UpperCamelCase__   )
                   self.assertEqual(len(UpperCamelCase__   ) ,       1   )

                   __UpperCamelCase   							=tokenizer.decode(UpperCamelCase__ ,       skip_special_tokens=UpperCamelCase__   )
                   self.assertTrue(special_token not in decoded   )






    def _a (      self   )  ->	Any:
         __UpperCamelCase   							=self.get_tokenizers()
         for tokenizer in tokenizers:
              with self.subTest(f'{tokenizer.__class__.__name__}'   ):
                   __UpperCamelCase   							=self.get_input_output_texts(UpperCamelCase__   )

                   __UpperCamelCase   							=tokenizer.tokenize(UpperCamelCase__   )
                   __UpperCamelCase   							=tokenizer.convert_tokens_to_ids(UpperCamelCase__   )
                   __UpperCamelCase   							=tokenizer.encode(UpperCamelCase__ ,       add_special_tokens=UpperCamelCase__   )
                   self.assertListEqual(UpperCamelCase__ ,       UpperCamelCase__   )

                   __UpperCamelCase   							=tokenizer.convert_ids_to_tokens(UpperCamelCase__   )
                   self.assertNotEqual(len(UpperCamelCase__   ) ,       0   )
                   __UpperCamelCase   							=tokenizer.decode(UpperCamelCase__   )
                   self.assertIsInstance(UpperCamelCase__ ,       UpperCamelCase__   )

                   self.assertEqual(text_a.replace(' ' ,       ''   ) ,       UpperCamelCase__   )






    @unittest.skip('MGP-STR tokenizer only handles one sequence.'   )
    def _a (      self   )  ->	Tuple:
         pass






    @unittest.skip('inputs cannot be pretokenized in MgpstrTokenizer'   )
    def _a (      self   )  ->	Tuple:
         pass









from ..utils import DummyObject, requires_backends






class    UpperCAmelCase__	( metaclass=A_		):



    """simple docstring"""






    UpperCAmelCase__						:		Any              =  ["speech"]






    def __init__(      self ,       *A_ ,       **A_   )  ->	Any:
         requires_backends(self ,       ['speech']   )






class    UpperCAmelCase__	( metaclass=A_		):



    """simple docstring"""






    UpperCAmelCase__						:		Union[str, Any]              =  ["speech"]






    def __init__(      self ,       *A_ ,       **A_   )  ->	Union[str, Any]:
         requires_backends(self ,       ['speech']   )





