


import shutil
import tempfile
import unittest

import numpy as np
import pytest

from transformers import is_speech_available, is_vision_available
from transformers.testing_utils import require_torch


if is_vision_available():
		from transformers import TvltImageProcessor

if is_speech_available():
		from transformers import TvltFeatureExtractor

from transformers import TvltProcessor





@require_torch
class  _a							(    unittest.TestCase):




	def 							UpperCAmelCase__( self						:		Optional[int]		)->	Optional[int]:
			lowerCAmelCase__       :      List[str]   					= '''ZinengTang/tvlt-base'''
			lowerCAmelCase__       :      Union[str, Any]   					= tempfile.mkdtemp()




	def 							UpperCAmelCase__( self						:		List[Any]		, **_SCREAMING_SNAKE_CASE						:		Optional[int]		)->	List[str]:
			return TvltImageProcessor.from_pretrained(self.checkpoint		, **__snake_case		)




	def 							UpperCAmelCase__( self						:		int		, **_SCREAMING_SNAKE_CASE						:		Any		)->	Union[str, Any]:
			return TvltFeatureExtractor.from_pretrained(self.checkpoint		, **__snake_case		)




	def 							UpperCAmelCase__( self						:		Union[str, Any]		)->	Dict:
			shutil.rmtree(self.tmpdirname		)




	def 							UpperCAmelCase__( self						:		List[Any]		)->	Any:
			lowerCAmelCase__       :      Dict   					= self.get_image_processor()
			lowerCAmelCase__       :      List[str]   					= self.get_feature_extractor()

			lowerCAmelCase__       :      List[Any]   					= TvltProcessor(image_processor=__snake_case		, feature_extractor=__snake_case		)
			processor.save_pretrained(self.tmpdirname		)
			lowerCAmelCase__       :      Union[str, Any]   					= TvltProcessor.from_pretrained(self.tmpdirname		)

			self.assertIsInstance(processor.feature_extractor		, __snake_case		)
			self.assertIsInstance(processor.image_processor		, __snake_case		)




	def 							UpperCAmelCase__( self						:		List[str]		)->	List[str]:
			lowerCAmelCase__       :      int   					= self.get_image_processor()
			lowerCAmelCase__       :      Optional[Any]   					= self.get_feature_extractor()

			lowerCAmelCase__       :      Optional[int]   					= TvltProcessor(image_processor=__snake_case		, feature_extractor=__snake_case		)

			lowerCAmelCase__       :      Tuple   					= np.ones([1_2000]		)

			lowerCAmelCase__       :      Dict   					= feature_extractor(__snake_case		, return_tensors='''np'''		)
			lowerCAmelCase__       :      List[str]   					= processor(audio=__snake_case		, return_tensors='''np'''		)

			for key in audio_dict.keys():
					self.assertAlmostEqual(audio_dict[key].sum()		, input_processor[key].sum()		, delta=1E-2		)




	def 							UpperCAmelCase__( self						:		List[str]		)->	str:
			lowerCAmelCase__       :      List[Any]   					= self.get_image_processor()
			lowerCAmelCase__       :      List[Any]   					= self.get_feature_extractor()

			lowerCAmelCase__       :      int   					= TvltProcessor(image_processor=__snake_case		, feature_extractor=__snake_case		)

			lowerCAmelCase__       :      List[Any]   					= np.ones([3, 224, 224]		)

			lowerCAmelCase__       :      List[Any]   					= image_processor(__snake_case		, return_tensors='''np'''		)
			lowerCAmelCase__       :      int   					= processor(images=__snake_case		, return_tensors='''np'''		)

			for key in image_dict.keys():
					self.assertAlmostEqual(image_dict[key].sum()		, input_processor[key].sum()		, delta=1E-2		)




	def 							UpperCAmelCase__( self						:		Tuple		)->	Optional[Any]:
			lowerCAmelCase__       :      Dict   					= self.get_image_processor()
			lowerCAmelCase__       :      Optional[int]   					= self.get_feature_extractor()

			lowerCAmelCase__       :      Optional[Any]   					= TvltProcessor(image_processor=__snake_case		, feature_extractor=__snake_case		)

			lowerCAmelCase__       :      Any   					= np.ones([1_2000]		)
			lowerCAmelCase__       :      Tuple   					= np.ones([3, 224, 224]		)

			lowerCAmelCase__       :      str   					= processor(audio=__snake_case		, images=__snake_case		)

			self.assertListEqual(list(inputs.keys()		)		, ['''audio_values''', '''audio_mask''', '''pixel_values''', '''pixel_mask''']		)

			# test if it raises when no input is passed
			with pytest.raises(__snake_case		):
					processor()




	def 							UpperCAmelCase__( self						:		Optional[Any]		)->	Union[str, Any]:
			lowerCAmelCase__       :      Union[str, Any]   					= self.get_image_processor()
			lowerCAmelCase__       :      Optional[Any]   					= self.get_feature_extractor()

			lowerCAmelCase__       :      List[str]   					= TvltProcessor(image_processor=__snake_case		, feature_extractor=__snake_case		)

			self.assertListEqual(
			    processor.model_input_names		, image_processor.model_input_names + feature_extractor.model_input_names		, msg='''`processor` and `image_processor`+`feature_extractor` model input names do not match'''		, )








def 					lowerCamelCase_   (	_a = 4_000_000	):




		"""simple docstring"""






		lowerCAmelCase__       :      str   					= []
		lowerCAmelCase__					,     lowerCAmelCase__       :      Optional[Any]   					= 0, 1
		while b <= n:
				if b % 2 == 0:
						even_fibs.append(_a	)
				lowerCAmelCase__					,     lowerCAmelCase__       :      Union[str, Any]   					= b, a + b
		return sum(_a	)


if __name__ == "__main__":
		print(f'''{solution() = }''')




