
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  ):





					def 		UpperCAmelCase(self				:   List[str]       )						->						Optional[int]:
									snake_case								= "ZinengTang/tvlt-base"
									snake_case								= tempfile.mkdtemp()





					def 		UpperCAmelCase(self				:   Union[str, Any]    ,   **_A				:   List[str]       )						->						List[Any]:
									return TvltImageProcessor.from_pretrained(self.checkpoint    ,   **_A       )





					def 		UpperCAmelCase(self				:   Dict    ,   **_A				:   Tuple       )						->						int:
									return TvltFeatureExtractor.from_pretrained(self.checkpoint    ,   **_A       )





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





					def 		UpperCAmelCase(self				:   Tuple       )						->						int:
									snake_case								= self.get_image_processor()
									snake_case								= self.get_feature_extractor()

									snake_case								= TvltProcessor(image_processor=_A    ,   feature_extractor=_A       )
									processor.save_pretrained(self.tmpdirname       )
									snake_case								= TvltProcessor.from_pretrained(self.tmpdirname       )

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





					def 		UpperCAmelCase(self				:   Any       )						->						int:
									snake_case								= self.get_image_processor()
									snake_case								= self.get_feature_extractor()

									snake_case								= TvltProcessor(image_processor=_A    ,   feature_extractor=_A       )

									snake_case								= np.ones([1_2_0_0_0]       )

									snake_case								= feature_extractor(_A    ,   return_tensors="np"       )
									snake_case								= processor(audio=_A    ,   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				:   Dict       )						->						str:
									snake_case								= self.get_image_processor()
									snake_case								= self.get_feature_extractor()

									snake_case								= TvltProcessor(image_processor=_A    ,   feature_extractor=_A       )

									snake_case								= np.ones([3, 2_2_4, 2_2_4]       )

									snake_case								= image_processor(_A    ,   return_tensors="np"       )
									snake_case								= processor(images=_A    ,   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				:   Dict       )						->						Any:
									snake_case								= self.get_image_processor()
									snake_case								= self.get_feature_extractor()

									snake_case								= TvltProcessor(image_processor=_A    ,   feature_extractor=_A       )

									snake_case								= np.ones([1_2_0_0_0]       )
									snake_case								= np.ones([3, 2_2_4, 2_2_4]       )

									snake_case								= processor(audio=_A    ,   images=_A       )

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





					def 		UpperCAmelCase(self				:   List[str]       )						->						Optional[Any]:
									snake_case								= self.get_image_processor()
									snake_case								= self.get_feature_extractor()

									snake_case								= TvltProcessor(image_processor=_A    ,   feature_extractor=_A       )

									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 						lowercase_      (       A__ = 1000		)							->							int:
    """simple docstring"""

    return sum(2 * a * ((a - 1) // 2) for a in range(3			,		n + 1		)		)


if __name__ == "__main__":
   print(solution())

