





'''simple docstring'''





from ...processing_utils import ProcessorMixin




class   UpperCamelCase_       (     SCREAMING_SNAKE_CASE__    ):
							lowerCamelCase_           =					["image_processor", "feature_extractor"]
							lowerCamelCase_           =					"TvltImageProcessor"
							lowerCamelCase_           =					"TvltFeatureExtractor"


							def __init__(							self    :Tuple							,				__A    :List[str]							,				__A    :List[Any]		)   ->   Tuple:



									"""simple docstring"""



									super().__init__(image_processor=snake_case__							,				feature_extractor=snake_case__		)

									SCREAMING_SNAKE_CASE__			=      image_processor
									SCREAMING_SNAKE_CASE__			=      feature_extractor


							def __call__(							self    :Dict							,				__A    :Dict=None							,				__A    :Any=None							,				__A    :Dict=None							,				__A    :Optional[Any]=None							,				__A    :Dict=False							,				__A    :Dict=False							,				*__A    :int							,				**__A    :List[str]							,				)   ->   str:



									"""simple docstring"""



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

									SCREAMING_SNAKE_CASE__			=      None
									if images is not None:
											SCREAMING_SNAKE_CASE__			=      self.image_processor(snake_case__							,				mask_pixel=snake_case__							,				*snake_case__							,				**snake_case__		)
									if images_mixed is not None:
											SCREAMING_SNAKE_CASE__			=      self.image_processor(snake_case__							,				is_mixed=snake_case__							,				*snake_case__							,				**snake_case__		)
									if audio is not None:
											SCREAMING_SNAKE_CASE__			=      self.feature_extractor(
											    snake_case__							,				*snake_case__							,				sampling_rate=snake_case__							,				mask_audio=snake_case__							,				**snake_case__		)

									SCREAMING_SNAKE_CASE__			=      {}
									if audio is not None:
											output_dict.update(snake_case__		)
									if images is not None:
											output_dict.update(snake_case__		)
									if images_mixed_dict is not None:
											output_dict.update(snake_case__		)
									return output_dict


							@property
							def      _snake_case  (							self    :List[Any]		)   ->   List[str]:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__			=      self.image_processor.model_input_names
									SCREAMING_SNAKE_CASE__			=      self.feature_extractor.model_input_names
									return list(dict.fromkeys(image_processor_input_names + feature_extractor_input_names		)		)






import json
import os
import unittest

from transformers import OpenAIGPTTokenizer, OpenAIGPTTokenizerFast
from transformers.models.openai.tokenization_openai import VOCAB_FILES_NAMES
from transformers.testing_utils import require_ftfy, require_spacy, require_tokenizers

from ...test_tokenization_common import TokenizerTesterMixin




@require_tokenizers
class   UpperCamelCase_       (     UpperCamelCase__				,  unittest.TestCase    ):
							lowerCamelCase_           =					OpenAIGPTTokenizer
							lowerCamelCase_           =					OpenAIGPTTokenizerFast
							lowerCamelCase_           =					True
							lowerCamelCase_           =					False


							def      _snake_case  (							self    :Optional[Any]		)   ->   Dict:



									"""simple docstring"""



									super().setUp()

									# Adapted from Sennrich et al. 2015 and https://github.com/rsennrich/subword-nmt
									SCREAMING_SNAKE_CASE__			=      [
									    """l""",
									    """o""",
									    """w""",
									    """e""",
									    """r""",
									    """s""",
									    """t""",
									    """i""",
									    """d""",
									    """n""",
									    """w</w>""",
									    """r</w>""",
									    """t</w>""",
									    """lo""",
									    """low""",
									    """er</w>""",
									    """low</w>""",
									    """lowest</w>""",
									    """newer</w>""",
									    """wider</w>""",
									    """<unk>""",
									]
									SCREAMING_SNAKE_CASE__			=      dict(zip(__A							,				range(len(__A		)		)		)		)
									SCREAMING_SNAKE_CASE__			=      ["""#version: 0.2""", """l o""", """lo w""", """e r</w>""", """"""]

									SCREAMING_SNAKE_CASE__			=      os.path.join(self.tmpdirname							,				VOCAB_FILES_NAMES["""vocab_file"""]		)
									SCREAMING_SNAKE_CASE__			=      os.path.join(self.tmpdirname							,				VOCAB_FILES_NAMES["""merges_file"""]		)
									with open(self.vocab_file							,				"""w"""		) as fp:
											fp.write(json.dumps(__A		)		)
									with open(self.merges_file							,				"""w"""		) as fp:
											fp.write("""\n""".join(__A		)		)


							def      _snake_case  (							self    :Union[str, Any]							,				__A    :str		)   ->   List[Any]:



									"""simple docstring"""



									return "lower newer", "lower newer"


							def      _snake_case  (							self    :Optional[Any]		)   ->   Tuple:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__			=      OpenAIGPTTokenizer(self.vocab_file							,				self.merges_file		)

									SCREAMING_SNAKE_CASE__			=      """lower"""
									SCREAMING_SNAKE_CASE__			=      ["""low""", """er</w>"""]
									SCREAMING_SNAKE_CASE__			=      tokenizer.tokenize(__A		)
									self.assertListEqual(__A							,				__A		)

									SCREAMING_SNAKE_CASE__			=      tokens + ["""<unk>"""]
									SCREAMING_SNAKE_CASE__			=      [14, 15, 20]
									self.assertListEqual(tokenizer.convert_tokens_to_ids(__A		)							,				__A		)


							def      _snake_case  (							self    :Optional[Any]							,				__A    :Optional[Any]=15		)   ->   Any:



									"""simple docstring"""



									for tokenizer, pretrained_name, kwargs in self.tokenizers_list:
											with self.subTest(f'''{tokenizer.__class__.__name__} ({pretrained_name})'''		):
													SCREAMING_SNAKE_CASE__			=      self.rust_tokenizer_class.from_pretrained(__A							,				**__A		)

													# Simple input
													SCREAMING_SNAKE_CASE__			=      """This is a simple input"""
													SCREAMING_SNAKE_CASE__			=      ["""This is a simple input 1""", """This is a simple input 2"""]
													SCREAMING_SNAKE_CASE__			=      ("""This is a simple input""", """This is a pair""")
													SCREAMING_SNAKE_CASE__			=      [
													    ("""This is a simple input 1""", """This is a simple input 2"""),
													    ("""This is a simple pair 1""", """This is a simple pair 2"""),
													]

													# Simple input tests
													self.assertRaises(__A							,				tokenizer_r.encode							,				__A							,				max_length=__A							,				padding="""max_length"""		)

													# Simple input
													self.assertRaises(__A							,				tokenizer_r.encode_plus							,				__A							,				max_length=__A							,				padding="""max_length"""		)

													# Simple input
													self.assertRaises(
													    __A							,				tokenizer_r.batch_encode_plus							,				__A							,				max_length=__A							,				padding="""max_length"""							,				)

													# Pair input
													self.assertRaises(__A							,				tokenizer_r.encode							,				__A							,				max_length=__A							,				padding="""max_length"""		)

													# Pair input
													self.assertRaises(__A							,				tokenizer_r.encode_plus							,				__A							,				max_length=__A							,				padding="""max_length"""		)

													# Pair input
													self.assertRaises(
													    __A							,				tokenizer_r.batch_encode_plus							,				__A							,				max_length=__A							,				padding="""max_length"""							,				)


							def      _snake_case  (							self    :Dict		)   ->   List[Any]:



									"""simple docstring"""



									pass




@require_ftfy
@require_spacy
@require_tokenizers
class   UpperCamelCase_       (     UpperCamelCase__    ):
							pass