






import os
import unittest

from transformers import LayoutLMTokenizer, LayoutLMTokenizerFast
from transformers.models.layoutlm.tokenization_layoutlm import VOCAB_FILES_NAMES
from transformers.testing_utils import require_tokenizers

from ...test_tokenization_common import TokenizerTesterMixin
@require_tokenizers
class 						lowerCamelCase_				(      lowerCamelCase			,				unittest.TestCase ):
				a__					       =  LayoutLMTokenizer
				a__					       =  LayoutLMTokenizerFast
				a__					       =  True
				a__					       =  True







				def 			A	(						self     ):
								"""simple docstring"""
								super().setUp()

								__magic_name__		:Any        =      [
								    '''[UNK]''',
								    '''[CLS]''',
								    '''[SEP]''',
								    '''want''',
								    '''##want''',
								    '''##ed''',
								    '''wa''',
								    '''un''',
								    '''runn''',
								    '''##ing''',
								    ''',''',
								    '''low''',
								    '''lowest''',
								]
								__magic_name__		:Dict        =      os.path.join(self.tmpdirname       ,					VOCAB_FILES_NAMES['''vocab_file''']     )
								with open(self.vocab_file       ,					'''w'''       ,					encoding='''utf-8'''     ) as vocab_writer:
												vocab_writer.write(''''''.join([x + '''\n''' for x in vocab_tokens]     )     )







				def 			A	(						self       ,					**__lowerCAmelCase     ):
								"""simple docstring"""
								return LayoutLMTokenizer.from_pretrained(self.tmpdirname       ,					**__lowerCAmelCase     )







				def 			A	(						self       ,					__lowerCAmelCase     ):
								"""simple docstring"""
								__magic_name__		:List[str]        =      '''UNwant\u00E9d,running'''
								__magic_name__		:Any        =      '''unwanted, running'''
								return input_text, output_text







				def 			A	(						self     ):
								"""simple docstring"""
								__magic_name__		:Union[str, Any]        =      self.tokenizer_class(self.vocab_file     )

								__magic_name__		:List[Any]        =      tokenizer.tokenize('''UNwant\u00E9d,running'''     )
								self.assertListEqual(__lowerCAmelCase       ,					['''un''', '''##want''', '''##ed''', ''',''', '''runn''', '''##ing''']     )
								self.assertListEqual(tokenizer.convert_tokens_to_ids(__lowerCAmelCase     )       ,					[7, 4, 5, 1_0, 8, 9]     )







				def 			A	(						self     ):
								"""simple docstring"""
								pass














from ...processing_utils import ProcessorMixin
class 						lowerCamelCase_				(      lowerCamelCase ):
				a__					       =  '''WhisperFeatureExtractor'''
				a__					       =  '''WhisperTokenizer'''







				def __init__(						self       ,					__lowerCAmelCase       ,					__lowerCAmelCase     ):
								"""simple docstring"""
								super().__init__(__lowerCAmelCase       ,					__lowerCAmelCase     )
								__magic_name__		:int        =      self.feature_extractor
								__magic_name__		:int        =      False







				def 			A	(						self       ,					__lowerCAmelCase=None       ,					__lowerCAmelCase=None       ,					__lowerCAmelCase=True     ):
								"""simple docstring"""
								return self.tokenizer.get_decoder_prompt_ids(task=__lowerCAmelCase       ,					language=__lowerCAmelCase       ,					no_timestamps=__lowerCAmelCase     )







				def __call__(						self       ,					*__lowerCAmelCase       ,					**__lowerCAmelCase     ):
								"""simple docstring"""
								# For backward compatibility
								if self._in_target_context_manager:
												return self.current_processor(*__lowerCAmelCase       ,					**__lowerCAmelCase     )

								__magic_name__		:List[Any]        =      kwargs.pop('''audio'''       ,					__lowerCAmelCase     )
								__magic_name__		:Any        =      kwargs.pop('''sampling_rate'''       ,					__lowerCAmelCase     )
								__magic_name__		:str        =      kwargs.pop('''text'''       ,					__lowerCAmelCase     )
								if len(__lowerCAmelCase     ) > 0:
												__magic_name__		:Any        =      args[0]
												__magic_name__		:Union[str, Any]        =      args[1:]

								if audio is None and text is None:
												raise ValueError('''You need to specify either an `audio` or `text` input to process.'''     )

								if audio is not None:
												__magic_name__		:Optional[int]        =      self.feature_extractor(__lowerCAmelCase       ,					*__lowerCAmelCase       ,					sampling_rate=__lowerCAmelCase       ,					**__lowerCAmelCase     )
								if text is not None:
												__magic_name__		:Optional[int]        =      self.tokenizer(__lowerCAmelCase       ,					**__lowerCAmelCase     )

								if text is None:
												return inputs

								elif audio is None:
												return encodings
								else:
												__magic_name__		:str        =      encodings['''input_ids''']
												return inputs







				def 			A	(						self       ,					*__lowerCAmelCase       ,					**__lowerCAmelCase     ):
								"""simple docstring"""
								return self.tokenizer.batch_decode(*__lowerCAmelCase       ,					**__lowerCAmelCase     )







				def 			A	(						self       ,					*__lowerCAmelCase       ,					**__lowerCAmelCase     ):
								"""simple docstring"""
								return self.tokenizer.decode(*__lowerCAmelCase       ,					**__lowerCAmelCase     )







				def 			A	(						self       ,					__lowerCAmelCase       ,					__lowerCAmelCase="np"     ):
								"""simple docstring"""
								return self.tokenizer.get_prompt_ids(__lowerCAmelCase       ,					return_tensors=__lowerCAmelCase     )






