
"""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   ):
							lowerCamelCase_					=  '''ZinengTang/tvlt-base'''
							lowerCamelCase_					=  tempfile.mkdtemp()




				def        UpperCAmelCase__						(				self							,						**UpperCAmelCase   ):
							return TvltImageProcessor.from_pretrained(self.checkpoint							,						**UpperCAmelCase   )




				def        UpperCAmelCase__						(				self							,						**UpperCAmelCase   ):
							return TvltFeatureExtractor.from_pretrained(self.checkpoint							,						**UpperCAmelCase   )




				def        UpperCAmelCase__						(				self   ):
							shutil.rmtree(self.tmpdirname   )




				def        UpperCAmelCase__						(				self   ):
							lowerCamelCase_					=  self.get_image_processor()
							lowerCamelCase_					=  self.get_feature_extractor()

							lowerCamelCase_					=  TvltProcessor(image_processor=UpperCAmelCase							,						feature_extractor=UpperCAmelCase   )
							processor.save_pretrained(self.tmpdirname   )
							lowerCamelCase_					=  TvltProcessor.from_pretrained(self.tmpdirname   )

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




				def        UpperCAmelCase__						(				self   ):
							lowerCamelCase_					=  self.get_image_processor()
							lowerCamelCase_					=  self.get_feature_extractor()

							lowerCamelCase_					=  TvltProcessor(image_processor=UpperCAmelCase							,						feature_extractor=UpperCAmelCase   )

							lowerCamelCase_					=  np.ones([1_2000]   )

							lowerCamelCase_					=  feature_extractor(UpperCAmelCase							,						return_tensors='''np'''   )
							lowerCamelCase_					=  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        UpperCAmelCase__						(				self   ):
							lowerCamelCase_					=  self.get_image_processor()
							lowerCamelCase_					=  self.get_feature_extractor()

							lowerCamelCase_					=  TvltProcessor(image_processor=UpperCAmelCase							,						feature_extractor=UpperCAmelCase   )

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

							lowerCamelCase_					=  image_processor(UpperCAmelCase							,						return_tensors='''np'''   )
							lowerCamelCase_					=  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        UpperCAmelCase__						(				self   ):
							lowerCamelCase_					=  self.get_image_processor()
							lowerCamelCase_					=  self.get_feature_extractor()

							lowerCamelCase_					=  TvltProcessor(image_processor=UpperCAmelCase							,						feature_extractor=UpperCAmelCase   )

							lowerCamelCase_					=  np.ones([1_2000]   )
							lowerCamelCase_					=  np.ones([3, 224, 224]   )

							lowerCamelCase_					=  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        UpperCAmelCase__						(				self   ):
							lowerCamelCase_					=  self.get_image_processor()
							lowerCamelCase_					=  self.get_feature_extractor()

							lowerCamelCase_					=  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'''							,						)









from collections import defaultdict


def 					_a							(					lowerCAmelCase    ,						lowerCAmelCase )->	bool:
		SCREAMING_SNAKE_CASE_					      =							first_str.lower().strip()
		SCREAMING_SNAKE_CASE_					      =							second_str.lower().strip()

		# Remove whitespace
		SCREAMING_SNAKE_CASE_					      =							first_str.replace(' '    ,						'' )
		SCREAMING_SNAKE_CASE_					      =							second_str.replace(' '    ,						'' )

		# Strings of different lengths are not anagrams
		if len(lowerCAmelCase ) != len(lowerCAmelCase ):
				return False

		# Default values for count should be 0
		SCREAMING_SNAKE_CASE_					      =							defaultdict(lowerCAmelCase )

		# For each character in input strings,
		# increment count in the corresponding
		for i in range(len(lowerCAmelCase ) ):
				count[first_str[i]] += 1
				count[second_str[i]] -= 1

		return all(_count == 0 for _count in count.values() )


if __name__ == "__main__":
						from doctest import testmod

						testmod()
						SCREAMING_SNAKE_CASE:     Dict									= input('''Enter the first string ''').strip()
						SCREAMING_SNAKE_CASE:     str									= input('''Enter the second string ''').strip()

						SCREAMING_SNAKE_CASE:     Optional[Any]									= check_anagrams(input_a, input_b)
						print(f"""{input_a} and {input_b} are {'' if status else 'not '}anagrams.""")