




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





						def       __UpperCamelCase     (							self      :	int)						->       Optional[int]:




											"""simple docstring"""







											_lowerCAmelCase:Optional[Any]									=  '''ZinengTang/tvlt-base'''
											_lowerCAmelCase:Tuple									=  tempfile.mkdtemp()





						def       __UpperCamelCase     (							self      :	Dict     ,**a__      :	Tuple)						->       Dict:




											"""simple docstring"""







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





						def       __UpperCamelCase     (							self      :	str     ,**a__      :	Any)						->       Any:




											"""simple docstring"""







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





						def       __UpperCamelCase     (							self      :	List[Any])						->       List[str]:




											"""simple docstring"""







											shutil.rmtree(self.tmpdirname)





						def       __UpperCamelCase     (							self      :	str)						->       Optional[Any]:




											"""simple docstring"""







											_lowerCAmelCase:Any									=  self.get_image_processor()
											_lowerCAmelCase:List[str]									=  self.get_feature_extractor()

											_lowerCAmelCase:List[str]									=  TvltProcessor(image_processor=a__     ,feature_extractor=a__)
											processor.save_pretrained(self.tmpdirname)
											_lowerCAmelCase:str									=  TvltProcessor.from_pretrained(self.tmpdirname)

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





						def       __UpperCamelCase     (							self      :	int)						->       Dict:




											"""simple docstring"""







											_lowerCAmelCase:Optional[Any]									=  self.get_image_processor()
											_lowerCAmelCase:List[Any]									=  self.get_feature_extractor()

											_lowerCAmelCase:Union[str, Any]									=  TvltProcessor(image_processor=a__     ,feature_extractor=a__)

											_lowerCAmelCase:Any									=  np.ones([1_2000])

											_lowerCAmelCase:Dict									=  feature_extractor(a__     ,return_tensors='''np''')
											_lowerCAmelCase:List[Any]									=  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      :	List[Any])						->       str:




											"""simple docstring"""







											_lowerCAmelCase:str									=  self.get_image_processor()
											_lowerCAmelCase:Any									=  self.get_feature_extractor()

											_lowerCAmelCase:Union[str, Any]									=  TvltProcessor(image_processor=a__     ,feature_extractor=a__)

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

											_lowerCAmelCase:int									=  image_processor(a__     ,return_tensors='''np''')
											_lowerCAmelCase:Dict									=  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      :	List[str])						->       List[str]:




											"""simple docstring"""







											_lowerCAmelCase:Union[str, Any]									=  self.get_image_processor()
											_lowerCAmelCase:Any									=  self.get_feature_extractor()

											_lowerCAmelCase:str									=  TvltProcessor(image_processor=a__     ,feature_extractor=a__)

											_lowerCAmelCase:List[str]									=  np.ones([1_2000])
											_lowerCAmelCase:int									=  np.ones([3, 224, 224])

											_lowerCAmelCase:Optional[Any]									=  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])						->       List[Any]:




											"""simple docstring"""







											_lowerCAmelCase:Union[str, Any]									=  self.get_image_processor()
											_lowerCAmelCase:Union[str, Any]									=  self.get_feature_extractor()

											_lowerCAmelCase:Optional[int]									=  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'''     ,)












"""simple docstring"""






import warnings

from ...utils import logging
from .image_processing_poolformer import PoolFormerImageProcessor


UpperCamelCase__						=			logging.get_logger(__name__)




class   a__			(       UpperCamelCase_  ):





						def __init__(							self      :	Dict     ,*a__      :	List[str]     ,**a__      :	str)						->       None:




											"""simple docstring"""







											warnings.warn(
											    '''The class PoolFormerFeatureExtractor is deprecated and will be removed in version 5 of Transformers.'''
											    ''' Please use PoolFormerImageProcessor instead.'''     ,a__     ,)
											super().__init__(*a__     ,**a__)






