



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 	lowerCamelCase_    ( unittest.TestCase						):






      '''simple docstring'''







      def 			SCREAMING_SNAKE_CASE__		(	self      :			Any )      ->				Tuple:
         A							:					Optional[int]              =						'ZinengTang/tvlt-base'
         A							:					Optional[int]              =						tempfile.mkdtemp()







      def 			SCREAMING_SNAKE_CASE__		(	self      :			Tuple	,	**__lowerCamelCase      :			Any )      ->				str:
         return TvltImageProcessor.from_pretrained(self.checkpoint	,	**UpperCAmelCase_ )







      def 			SCREAMING_SNAKE_CASE__		(	self      :			str	,	**__lowerCamelCase      :			int )      ->				Dict:
         return TvltFeatureExtractor.from_pretrained(self.checkpoint	,	**UpperCAmelCase_ )







      def 			SCREAMING_SNAKE_CASE__		(	self      :			Dict )      ->				Optional[int]:
         shutil.rmtree(self.tmpdirname )







      def 			SCREAMING_SNAKE_CASE__		(	self      :			Tuple )      ->				List[Any]:
         A							:					Dict              =						self.get_image_processor()
         A							:					Union[str, Any]              =						self.get_feature_extractor()

         A							:					Any              =						TvltProcessor(image_processor=UpperCAmelCase_	,	feature_extractor=UpperCAmelCase_ )
         processor.save_pretrained(self.tmpdirname )
         A							:					Union[str, Any]              =						TvltProcessor.from_pretrained(self.tmpdirname )

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







      def 			SCREAMING_SNAKE_CASE__		(	self      :			Optional[int] )      ->				Dict:
         A							:					Optional[int]              =						self.get_image_processor()
         A							:					Tuple              =						self.get_feature_extractor()

         A							:					Union[str, Any]              =						TvltProcessor(image_processor=UpperCAmelCase_	,	feature_extractor=UpperCAmelCase_ )

         A							:					List[str]              =						np.ones([1_20_00] )

         A							:					Optional[Any]              =						feature_extractor(UpperCAmelCase_	,	return_tensors="np" )
         A							:					Optional[Any]              =						processor(audio=UpperCAmelCase_	,	return_tensors="np" )

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







      def 			SCREAMING_SNAKE_CASE__		(	self      :			Optional[int] )      ->				int:
         A							:					int              =						self.get_image_processor()
         A							:					Optional[int]              =						self.get_feature_extractor()

         A							:					Union[str, Any]              =						TvltProcessor(image_processor=UpperCAmelCase_	,	feature_extractor=UpperCAmelCase_ )

         A							:					Dict              =						np.ones([3, 2_24, 2_24] )

         A							:					str              =						image_processor(UpperCAmelCase_	,	return_tensors="np" )
         A							:					Any              =						processor(images=UpperCAmelCase_	,	return_tensors="np" )

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







      def 			SCREAMING_SNAKE_CASE__		(	self      :			Union[str, Any] )      ->				Optional[int]:
         A							:					List[Any]              =						self.get_image_processor()
         A							:					List[Any]              =						self.get_feature_extractor()

         A							:					Tuple              =						TvltProcessor(image_processor=UpperCAmelCase_	,	feature_extractor=UpperCAmelCase_ )

         A							:					int              =						np.ones([1_20_00] )
         A							:					Optional[Any]              =						np.ones([3, 2_24, 2_24] )

         A							:					str              =						processor(audio=UpperCAmelCase_	,	images=UpperCAmelCase_ )

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







      def 			SCREAMING_SNAKE_CASE__		(	self      :			Any )      ->				List[Any]:
         A							:					Tuple              =						self.get_image_processor()
         A							:					Dict              =						self.get_feature_extractor()

         A							:					Dict              =						TvltProcessor(image_processor=UpperCAmelCase_	,	feature_extractor=UpperCAmelCase_ )

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




from math import sqrt




def 	UpperCAmelCase   (						_lowerCamelCase = 100_0000    ):
			A							:					int              =						0
			A							:					int              =						0
			A							:					int

			while num_cuboids <= limit:
						max_cuboid_size += 1
						for sum_shortest_sides in range(2 ,    2 * max_cuboid_size + 1    ):
									if sqrt(sum_shortest_sides**2 + max_cuboid_size**2    ).is_integer():
												num_cuboids += (
												    min(_lowerCamelCase ,    sum_shortest_sides // 2    )
												    - max(1 ,    sum_shortest_sides - max_cuboid_size    )
												    + 1
												)

			return max_cuboid_size


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