



'''simple docstring'''
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 							__A				(   self )				->   Union[str, Any]:

					'''simple docstring'''
					__UpperCAmelCase      :					int   =   "ZinengTang/tvlt-base"
					__UpperCAmelCase      :					str   =   tempfile.mkdtemp()





		def 							__A				(   self       ,				**__UpperCAmelCase )				->   Tuple:

					'''simple docstring'''
					return TvltImageProcessor.from_pretrained(self.checkpoint       ,				**lowerCamelCase__ )





		def 							__A				(   self       ,				**__UpperCAmelCase )				->   Tuple:

					'''simple docstring'''
					return TvltFeatureExtractor.from_pretrained(self.checkpoint       ,				**lowerCamelCase__ )





		def 							__A				(   self )				->   int:

					'''simple docstring'''
					shutil.rmtree(self.tmpdirname )





		def 							__A				(   self )				->   Any:

					'''simple docstring'''
					__UpperCAmelCase      :					Dict   =   self.get_image_processor()
					__UpperCAmelCase      :					Any   =   self.get_feature_extractor()

					__UpperCAmelCase      :					List[Any]   =   TvltProcessor(image_processor=lowerCamelCase__       ,				feature_extractor=lowerCamelCase__ )
					processor.save_pretrained(self.tmpdirname )
					__UpperCAmelCase      :					str   =   TvltProcessor.from_pretrained(self.tmpdirname )

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





		def 							__A				(   self )				->   Tuple:

					'''simple docstring'''
					__UpperCAmelCase      :					List[str]   =   self.get_image_processor()
					__UpperCAmelCase      :					Union[str, Any]   =   self.get_feature_extractor()

					__UpperCAmelCase      :					List[str]   =   TvltProcessor(image_processor=lowerCamelCase__       ,				feature_extractor=lowerCamelCase__ )

					__UpperCAmelCase      :					str   =   np.ones([12_000] )

					__UpperCAmelCase      :					Tuple   =   feature_extractor(lowerCamelCase__       ,				return_tensors="""np""" )
					__UpperCAmelCase      :					List[str]   =   processor(audio=lowerCamelCase__       ,				return_tensors="""np""" )

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





		def 							__A				(   self )				->   Dict:

					'''simple docstring'''
					__UpperCAmelCase      :					List[str]   =   self.get_image_processor()
					__UpperCAmelCase      :					Optional[int]   =   self.get_feature_extractor()

					__UpperCAmelCase      :					List[Any]   =   TvltProcessor(image_processor=lowerCamelCase__       ,				feature_extractor=lowerCamelCase__ )

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

					__UpperCAmelCase      :					int   =   image_processor(lowerCamelCase__       ,				return_tensors="""np""" )
					__UpperCAmelCase      :					Any   =   processor(images=lowerCamelCase__       ,				return_tensors="""np""" )

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





		def 							__A				(   self )				->   Tuple:

					'''simple docstring'''
					__UpperCAmelCase      :					Union[str, Any]   =   self.get_image_processor()
					__UpperCAmelCase      :					Dict   =   self.get_feature_extractor()

					__UpperCAmelCase      :					Union[str, Any]   =   TvltProcessor(image_processor=lowerCamelCase__       ,				feature_extractor=lowerCamelCase__ )

					__UpperCAmelCase      :					Optional[Any]   =   np.ones([12_000] )
					__UpperCAmelCase      :					Any   =   np.ones([3, 224, 224] )

					__UpperCAmelCase      :					Optional[Any]   =   processor(audio=lowerCamelCase__       ,				images=lowerCamelCase__ )

					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(lowerCamelCase__ ):
								processor()





		def 							__A				(   self )				->   Optional[int]:

					'''simple docstring'''
					__UpperCAmelCase      :					Union[str, Any]   =   self.get_image_processor()
					__UpperCAmelCase      :					Tuple   =   self.get_feature_extractor()

					__UpperCAmelCase      :					int   =   TvltProcessor(image_processor=lowerCamelCase__       ,				feature_extractor=lowerCamelCase__ )

					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"""       ,				)








'''simple docstring'''


def        __lowerCAmelCase       (__lowerCAmelCase = 50      ):
		_UpperCAmelCase						:				Tuple	    =					[[0] * 3 for _ in range(length + 1      )]

		for row_length in range(length + 1      ):
				for tile_length in range(2					,       5      ):
						for tile_start in range(row_length - tile_length + 1      ):
								different_colour_ways_number[row_length][tile_length - 2] += (
								    different_colour_ways_number[row_length - tile_start - tile_length][
								        tile_length - 2
								    ]
								    + 1
								)

		return sum(different_colour_ways_number[length]      )


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



