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







				def 							__UpperCAmelCase					( self    :       List[Any]						):

					"""simple docstring"""






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







				def 							__UpperCAmelCase					( self    :       int			,					**lowerCamelCase_    :       List[str]						):

					"""simple docstring"""






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







				def 							__UpperCAmelCase					( self    :       List[Any]			,					**lowerCamelCase_    :       int						):

					"""simple docstring"""






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







				def 							__UpperCAmelCase					( self    :       Any						):

					"""simple docstring"""






					shutil.rmtree(self.tmpdirname						)







				def 							__UpperCAmelCase					( self    :       str						):

					"""simple docstring"""






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

					_lowercase :    List[str]							=							TvltProcessor(image_processor=lowerCamelCase_			,					feature_extractor=lowerCamelCase_						)
					processor.save_pretrained(self.tmpdirname						)
					_lowercase :    Optional[int]							=							TvltProcessor.from_pretrained(self.tmpdirname						)

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







				def 							__UpperCAmelCase					( self    :       int						):

					"""simple docstring"""






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

					_lowercase :    List[str]							=							TvltProcessor(image_processor=lowerCamelCase_			,					feature_extractor=lowerCamelCase_						)

					_lowercase :    List[Any]							=							np.ones([1_2_0_0_0]						)

					_lowercase :    Optional[int]							=							feature_extractor(lowerCamelCase_			,					return_tensors='np'						)
					_lowercase :    Tuple							=							processor(audio=lowerCamelCase_			,					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    :       Optional[int]						):

					"""simple docstring"""






					_lowercase :    Optional[int]							=							self.get_image_processor()
					_lowercase :    Optional[int]							=							self.get_feature_extractor()

					_lowercase :    Tuple							=							TvltProcessor(image_processor=lowerCamelCase_			,					feature_extractor=lowerCamelCase_						)

					_lowercase :    List[Any]							=							np.ones([3, 2_2_4, 2_2_4]						)

					_lowercase :    Any							=							image_processor(lowerCamelCase_			,					return_tensors='np'						)
					_lowercase :    List[str]							=							processor(images=lowerCamelCase_			,					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    :       Optional[int]						):

					"""simple docstring"""






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

					_lowercase :    Any							=							TvltProcessor(image_processor=lowerCamelCase_			,					feature_extractor=lowerCamelCase_						)

					_lowercase :    Union[str, Any]							=							np.ones([1_2_0_0_0]						)
					_lowercase :    List[str]							=							np.ones([3, 2_2_4, 2_2_4]						)

					_lowercase :    Tuple							=							processor(audio=lowerCamelCase_			,					images=lowerCamelCase_						)

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







				def 							__UpperCAmelCase					( self    :       List[str]						):

					"""simple docstring"""






					_lowercase :    Optional[Any]							=							self.get_image_processor()
					_lowercase :    Optional[int]							=							self.get_feature_extractor()

					_lowercase :    str							=							TvltProcessor(image_processor=lowerCamelCase_			,					feature_extractor=lowerCamelCase_						)

					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"""







from typing import Any


def      __lowerCAmelCase(		__UpperCAmelCase			):






	"""simple docstring"""





	if not input_list:
		return []
	_lowercase :    List[str]							=							[input_list.count(__UpperCAmelCase			) for value in input_list]
	_lowercase :    Optional[int]							=							max(__UpperCAmelCase			)  # Gets the maximum count in the input list.
	# Gets values of modes
	return sorted({input_list[i] for i, value in enumerate(__UpperCAmelCase			) if value == y}			)


if __name__ == "__main__":
						import doctest

						doctest.testmod()



