






import json
import os
import unittest

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

from ...test_tokenization_common import TokenizerTesterMixin






class 		lowercase_					(	lowercase ,  unittest.TestCase   ):






      '''simple docstring'''




      __snake_case       =  CTRLTokenizer
      __snake_case       =  False
      __snake_case       =  False







      def       __lowerCAmelCase					(      self      :						Tuple  )    ->Any:




       """simple docstring"""


       super().setUp()

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

       a		  =      os.path.join(self.tmpdirname ,					VOCAB_FILES_NAMES['''vocab_file''']  )
       a		  =      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(lowerCamelCase__  ) + '''\n'''  )
       with open(self.merges_file ,					'''w''' ,					encoding='''utf-8'''  ) as fp:
        fp.write('''\n'''.join(lowerCamelCase__  )  )







      def       __lowerCAmelCase					(      self      :						Tuple ,					**__UpperCAmelCase      :						Optional[int]  )    ->Tuple:




       """simple docstring"""


       kwargs.update(self.special_tokens_map  )
       return CTRLTokenizer.from_pretrained(self.tmpdirname ,					**lowerCamelCase__  )







      def       __lowerCAmelCase					(      self      :						Dict ,					__UpperCAmelCase      :						Optional[Any]  )    ->int:




       """simple docstring"""


       a		  =      '''adapt react readapt apt'''
       a		  =      '''adapt react readapt apt'''
       return input_text, output_text







      def       __lowerCAmelCase					(      self      :						List[str]  )    ->List[Any]:




       """simple docstring"""


       a		  =      CTRLTokenizer(self.vocab_file ,					self.merges_file ,					**self.special_tokens_map  )
       a		  =      '''adapt react readapt apt'''
       a		  =      '''adapt re@@ a@@ c@@ t re@@ adapt apt'''.split()
       a		  =      tokenizer.tokenize(lowerCamelCase__  )
       self.assertListEqual(lowerCamelCase__ ,					lowerCamelCase__  )

       a		  =      tokens + [tokenizer.unk_token]

       a		  =      [0, 1, 2, 4, 5, 1, 0, 3, 6]
       self.assertListEqual(tokenizer.convert_tokens_to_ids(lowerCamelCase__  ) ,					lowerCamelCase__  )








from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_speech_available, is_torch_available


__A        =    {
    "configuration_audio_spectrogram_transformer": [
        "AUDIO_SPECTROGRAM_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP",
        "ASTConfig",
    ]
}

try:
					if not is_torch_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					__A        =    [
					    "AUDIO_SPECTROGRAM_TRANSFORMER_PRETRAINED_MODEL_ARCHIVE_LIST",
					    "ASTForAudioClassification",
					    "ASTModel",
					    "ASTPreTrainedModel",
					]

try:
					if not is_speech_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					__A        =    ["ASTFeatureExtractor"]

if TYPE_CHECKING:
					from .configuration_audio_spectrogram_transformer import (
					    AUDIO_SPECTROGRAM_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP,
					    ASTConfig,
					)

					try:
										if not is_torch_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .modeling_audio_spectrogram_transformer import (
										    AUDIO_SPECTROGRAM_TRANSFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
										    ASTForAudioClassification,
										    ASTModel,
										    ASTPreTrainedModel,
										)

					try:
										if not is_speech_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .feature_extraction_audio_spectrogram_transformer import ASTFeatureExtractor


else:
					import sys

					__A        =    _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)


