
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 				SCREAMING_SNAKE_CASE_		(     self				)    ->      Union[str, Any]:


								'''simple docstring'''




								__a										=    '''ZinengTang/tvlt-base'''
								__a										=    tempfile.mkdtemp()




				def 				SCREAMING_SNAKE_CASE_		(     self		,     **_snake_case				)    ->      List[str]:


								'''simple docstring'''




								return TvltImageProcessor.from_pretrained(self.checkpoint		,     **_snake_case				)




				def 				SCREAMING_SNAKE_CASE_		(     self		,     **_snake_case				)    ->      Union[str, Any]:


								'''simple docstring'''




								return TvltFeatureExtractor.from_pretrained(self.checkpoint		,     **_snake_case				)




				def 				SCREAMING_SNAKE_CASE_		(     self				)    ->      List[Any]:


								'''simple docstring'''




								shutil.rmtree(self.tmpdirname				)




				def 				SCREAMING_SNAKE_CASE_		(     self				)    ->      Union[str, Any]:


								'''simple docstring'''




								__a										=    self.get_image_processor()
								__a										=    self.get_feature_extractor()

								__a										=    TvltProcessor(image_processor=_snake_case		,     feature_extractor=_snake_case				)
								processor.save_pretrained(self.tmpdirname				)
								__a										=    TvltProcessor.from_pretrained(self.tmpdirname				)

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




				def 				SCREAMING_SNAKE_CASE_		(     self				)    ->      Union[str, Any]:


								'''simple docstring'''




								__a										=    self.get_image_processor()
								__a										=    self.get_feature_extractor()

								__a										=    TvltProcessor(image_processor=_snake_case		,     feature_extractor=_snake_case				)

								__a										=    np.ones([12_000]				)

								__a										=    feature_extractor(_snake_case		,     return_tensors='''np'''				)
								__a										=    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 				SCREAMING_SNAKE_CASE_		(     self				)    ->      str:


								'''simple docstring'''




								__a										=    self.get_image_processor()
								__a										=    self.get_feature_extractor()

								__a										=    TvltProcessor(image_processor=_snake_case		,     feature_extractor=_snake_case				)

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

								__a										=    image_processor(_snake_case		,     return_tensors='''np'''				)
								__a										=    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 				SCREAMING_SNAKE_CASE_		(     self				)    ->      List[Any]:


								'''simple docstring'''




								__a										=    self.get_image_processor()
								__a										=    self.get_feature_extractor()

								__a										=    TvltProcessor(image_processor=_snake_case		,     feature_extractor=_snake_case				)

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

								__a										=    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 				SCREAMING_SNAKE_CASE_		(     self				)    ->      Optional[Any]:


								'''simple docstring'''




								__a										=    self.get_image_processor()
								__a										=    self.get_feature_extractor()

								__a										=    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'''		,     )
UpperCamelCase  							=						[0, 2, 4, 6, 8]
UpperCamelCase  							=						[1, 3, 5, 7, 9]

def 			lowercase_				(			_lowerCamelCase							:       int		,	_lowerCamelCase							:       int		,	_lowerCamelCase							:       list[int]		,	_lowerCamelCase							:       int):
    if remaining_length == 0:
        if digits[0] == 0 or digits[-1] == 0:
            return 0

        for i in range(length // 2 - 1		,	-1		,	-1):
            remainder += digits[i] + digits[length - i - 1]

            if remainder % 2 == 0:
                return 0

            remainder //= 10

        return 1

    if remaining_length == 1:
        if remainder % 2 == 0:
            return 0

        lowercase__ :   str    					=				0
        for digit in range(10):
            lowercase__ :   str    					=				digit
            result += reversible_numbers(
                0		,	(remainder + 2 * digit) // 10		,	_lowerCamelCase		,	_lowerCamelCase)
        return result

    lowercase__ :   Dict    					=				0
    for digita in range(10):
        lowercase__ :   int    					=				digita

        if (remainder + digita) % 2 == 0:
            lowercase__ :   Optional[Any]    					=				ODD_DIGITS
        else:
            lowercase__ :   str    					=				EVEN_DIGITS

        for digita in other_parity_digits:
            lowercase__ :   List[str]    					=				digita
            result += reversible_numbers(
                remaining_length - 2		,	(remainder + digita + digita) // 10		,	_lowerCamelCase		,	_lowerCamelCase		,	)
    return result

def 			lowercase_				(			_lowerCamelCase							:       int = 9):
    lowercase__ :   Tuple    					=				0
    for length in range(1		,	max_power + 1):
        result += reversible_numbers(_lowerCamelCase		,	0		,	[0] * length		,	_lowerCamelCase)
    return result


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



