


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






     def  a_					(			self		)       ->    Optional[int]:
          _a						=		"ZinengTang/tvlt-base"
          _a						=		tempfile.mkdtemp()






     def  a_					(			self     ,							**__UpperCamelCase		)       ->    Optional[Any]:
          return TvltImageProcessor.from_pretrained(self.checkpoint     ,							**__UpperCamelCase		)






     def  a_					(			self     ,							**__UpperCamelCase		)       ->    Dict:
          return TvltFeatureExtractor.from_pretrained(self.checkpoint     ,							**__UpperCamelCase		)






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






     def  a_					(			self		)       ->    Dict:
          _a						=		self.get_image_processor()
          _a						=		self.get_feature_extractor()

          _a						=		TvltProcessor(image_processor=__UpperCamelCase     ,							feature_extractor=__UpperCamelCase		)
          processor.save_pretrained(self.tmpdirname		)
          _a						=		TvltProcessor.from_pretrained(self.tmpdirname		)

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






     def  a_					(			self		)       ->    Dict:
          _a						=		self.get_image_processor()
          _a						=		self.get_feature_extractor()

          _a						=		TvltProcessor(image_processor=__UpperCamelCase     ,							feature_extractor=__UpperCamelCase		)

          _a						=		np.ones([12_000]		)

          _a						=		feature_extractor(__UpperCamelCase     ,							return_tensors="np"		)
          _a						=		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  a_					(			self		)       ->    Tuple:
          _a						=		self.get_image_processor()
          _a						=		self.get_feature_extractor()

          _a						=		TvltProcessor(image_processor=__UpperCamelCase     ,							feature_extractor=__UpperCamelCase		)

          _a						=		np.ones([3, 224, 224]		)

          _a						=		image_processor(__UpperCamelCase     ,							return_tensors="np"		)
          _a						=		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  a_					(			self		)       ->    Any:
          _a						=		self.get_image_processor()
          _a						=		self.get_feature_extractor()

          _a						=		TvltProcessor(image_processor=__UpperCamelCase     ,							feature_extractor=__UpperCamelCase		)

          _a						=		np.ones([12_000]		)
          _a						=		np.ones([3, 224, 224]		)

          _a						=		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  a_					(			self		)       ->    Dict:
          _a						=		self.get_image_processor()
          _a						=		self.get_feature_extractor()

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





'''simple docstring'''

lowercase__				     =		65_521






def __UpperCamelCase   (			__lowerCamelCase		: str				)      ->     int:







     '''simple docstring'''






     _a						=		1
     _a						=		0
     for plain_chr in plain_text:
          _a						=		(a + ord(__lowerCamelCase				)) % MOD_ADLER
          _a						=		(b + a) % MOD_ADLER
     return (b << 16) | a

