




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






    """simple docstring"""





    def 							a__				(				self  )			->		Optional[int]:
         UpperCAmelCase_      :							Dict       =      '''ZinengTang/tvlt-base'''
         UpperCAmelCase_      :							Any       =      tempfile.mkdtemp()





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





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





    def 							a__				(				self  )			->		Dict:
         shutil.rmtree(self.tmpdirname  )





    def 							a__				(				self  )			->		Any:
         UpperCAmelCase_      :							Any       =      self.get_image_processor()
         UpperCAmelCase_      :							int       =      self.get_feature_extractor()

         UpperCAmelCase_      :							Optional[int]       =      TvltProcessor(image_processor=__snake_case       ,feature_extractor=__snake_case  )
         processor.save_pretrained(self.tmpdirname  )
         UpperCAmelCase_      :							int       =      TvltProcessor.from_pretrained(self.tmpdirname  )

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





    def 							a__				(				self  )			->		List[str]:
         UpperCAmelCase_      :							int       =      self.get_image_processor()
         UpperCAmelCase_      :							Tuple       =      self.get_feature_extractor()

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

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

         UpperCAmelCase_      :							str       =      feature_extractor(__snake_case       ,return_tensors='''np'''  )
         UpperCAmelCase_      :							Dict       =      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 							a__				(				self  )			->		str:
         UpperCAmelCase_      :							Dict       =      self.get_image_processor()
         UpperCAmelCase_      :							Optional[Any]       =      self.get_feature_extractor()

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

         UpperCAmelCase_      :							Dict       =      np.ones([3, 224, 224]  )

         UpperCAmelCase_      :							int       =      image_processor(__snake_case       ,return_tensors='''np'''  )
         UpperCAmelCase_      :							List[str]       =      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 							a__				(				self  )			->		Optional[Any]:
         UpperCAmelCase_      :							str       =      self.get_image_processor()
         UpperCAmelCase_      :							Optional[Any]       =      self.get_feature_extractor()

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

         UpperCAmelCase_      :							Any       =      np.ones([12_000]  )
         UpperCAmelCase_      :							Union[str, Any]       =      np.ones([3, 224, 224]  )

         UpperCAmelCase_      :							Optional[Any]       =      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 							a__				(				self  )			->		Union[str, Any]:
         UpperCAmelCase_      :							Tuple       =      self.get_image_processor()
         UpperCAmelCase_      :							Union[str, Any]       =      self.get_feature_extractor()

         UpperCAmelCase_      :							Dict       =      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'''       ,)





from math import ceil







def lowerCamelCase__       (      _lowercase = 1001				):

     '''simple docstring'''


     UpperCAmelCase_      :							Optional[Any]       =      1

     for i in range(1			,						int(ceil(n / 2.0				)				)				):
          UpperCAmelCase_      :							List[Any]       =      2 * i + 1
          UpperCAmelCase_      :							Optional[int]       =      2 * i
          UpperCAmelCase_      :							Any       =      total + 4 * odd**2 - 6 * even

     return total


if __name__ == "__main__":
     import sys

     if len(sys.argv) == 1:
          print(solution())
     else:
          try:
               __a          =			int(sys.argv[1])
               print(solution(n))
          except ValueError:
               print('Invalid entry - please enter a number')