

'''simple docstring'''





import unittest

from transformers import (
    MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING,
    TF_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING,
    TextaTextGenerationPipeline,
    pipeline,
)
from transformers.testing_utils import is_pipeline_test, require_tf, require_torch
from transformers.utils import is_torch_available

from .test_pipelines_common import ANY


if is_torch_available():
							import torch





@is_pipeline_test
class 		__SCREAMING_SNAKE_CASE       ( unittest.TestCase			):
				lowerCamelCase_							=						MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING
				lowerCamelCase_							=						TF_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING







				def    lowerCamelCase_  (					self    :		Optional[int]		,				UpperCAmelCase__    :		Optional[Any]		,				UpperCAmelCase__    :		Dict		,				UpperCAmelCase__    :		List[Any]      ):
										'''simple docstring'''
										lowercase   :       int								=TextaTextGenerationPipeline(model=UpperCAmelCase__		,				tokenizer=UpperCAmelCase__      )
										return generator, ["Something to write", "Something else"]







				def    lowerCamelCase_  (					self    :		Any		,				UpperCAmelCase__    :		Optional[int]		,				UpperCAmelCase__    :		Tuple      ):
										'''simple docstring'''
										lowercase   :       Optional[Any]								=generator('''Something there'''      )
										self.assertEqual(UpperCAmelCase__		,				[{'''generated_text''': ANY(UpperCAmelCase__      )}]      )
										# These are encoder decoder, they don't just append to incoming string
										self.assertFalse(outputs[0]['''generated_text'''].startswith('''Something there'''      )      )

										lowercase   :       Optional[Any]								=generator(['''This is great !''', '''Something else''']		,				num_return_sequences=2		,				do_sample=UpperCAmelCase__      )
										self.assertEqual(
										    UpperCAmelCase__		,				[
										        [{'''generated_text''': ANY(UpperCAmelCase__      )}, {'''generated_text''': ANY(UpperCAmelCase__      )}],
										        [{'''generated_text''': ANY(UpperCAmelCase__      )}, {'''generated_text''': ANY(UpperCAmelCase__      )}],
										    ]		,				)

										lowercase   :       Tuple								=generator(
										    ['''This is great !''', '''Something else''']		,				num_return_sequences=2		,				batch_size=2		,				do_sample=UpperCAmelCase__      )
										self.assertEqual(
										    UpperCAmelCase__		,				[
										        [{'''generated_text''': ANY(UpperCAmelCase__      )}, {'''generated_text''': ANY(UpperCAmelCase__      )}],
										        [{'''generated_text''': ANY(UpperCAmelCase__      )}, {'''generated_text''': ANY(UpperCAmelCase__      )}],
										    ]		,				)

										with self.assertRaises(UpperCAmelCase__      ):
																generator(4      )







				@require_torch
				def    lowerCamelCase_  (					self    :		Dict      ):
										'''simple docstring'''
										lowercase   :       str								=pipeline('''text2text-generation'''		,				model='''patrickvonplaten/t5-tiny-random'''		,				framework='''pt'''      )
										# do_sample=False necessary for reproducibility
										lowercase   :       int								=generator('''Something there'''		,				do_sample=UpperCAmelCase__      )
										self.assertEqual(UpperCAmelCase__		,				[{'''generated_text''': ''''''}]      )

										lowercase   :       Any								=3
										lowercase   :       Optional[Any]								=generator(
										    '''Something there'''		,				num_return_sequences=UpperCAmelCase__		,				num_beams=UpperCAmelCase__		,				)
										lowercase   :       Optional[int]								=[
										    {'''generated_text''': '''Beide Beide Beide Beide Beide Beide Beide Beide Beide'''},
										    {'''generated_text''': '''Beide Beide Beide Beide Beide Beide Beide Beide'''},
										    {'''generated_text''': ''''''},
										]
										self.assertEqual(UpperCAmelCase__		,				UpperCAmelCase__      )

										lowercase   :       Optional[Any]								=generator('''This is a test'''		,				do_sample=UpperCAmelCase__		,				num_return_sequences=2		,				return_tensors=UpperCAmelCase__      )
										self.assertEqual(
										    UpperCAmelCase__		,				[
										        {'''generated_token_ids''': ANY(torch.Tensor      )},
										        {'''generated_token_ids''': ANY(torch.Tensor      )},
										    ]		,				)
										lowercase   :       Any								=generator.model.config.eos_token_id
										lowercase   :       Optional[int]								='''<pad>'''
										lowercase   :       Tuple								=generator(
										    ['''This is a test''', '''This is a second test''']		,				do_sample=UpperCAmelCase__		,				num_return_sequences=2		,				batch_size=2		,				return_tensors=UpperCAmelCase__		,				)
										self.assertEqual(
										    UpperCAmelCase__		,				[
										        [
										            {'''generated_token_ids''': ANY(torch.Tensor      )},
										            {'''generated_token_ids''': ANY(torch.Tensor      )},
										        ],
										        [
										            {'''generated_token_ids''': ANY(torch.Tensor      )},
										            {'''generated_token_ids''': ANY(torch.Tensor      )},
										        ],
										    ]		,				)







				@require_tf
				def    lowerCamelCase_  (					self    :		Tuple      ):
										'''simple docstring'''
										lowercase   :       List[str]								=pipeline('''text2text-generation'''		,				model='''patrickvonplaten/t5-tiny-random'''		,				framework='''tf'''      )
										# do_sample=False necessary for reproducibility
										lowercase   :       List[str]								=generator('''Something there'''		,				do_sample=UpperCAmelCase__      )
										self.assertEqual(UpperCAmelCase__		,				[{'''generated_text''': ''''''}]      )








'''simple docstring'''





from collections import defaultdict






def 							_lowerCAmelCase (      __magic_name__	:    str      ,   __magic_name__	:    str	)							->     bool:
						lowercase   :       Optional[int]								=first_str.lower().strip()
						lowercase   :       Union[str, Any]								=second_str.lower().strip()

						# Remove whitespace
						lowercase   :       Optional[int]								=first_str.replace(''' '''      ,   ''''''	)
						lowercase   :       Optional[Any]								=second_str.replace(''' '''      ,   ''''''	)

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

						# Default values for count should be 0
						lowercase   :       defaultdict[str, int]								=defaultdict(__magic_name__	)

						# For each character in input strings,
						# increment count in the corresponding
						for i in range(len(__magic_name__	)	):
												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()
							UpperCamelCase_							=					input("""Enter the first string """).strip()
							UpperCamelCase_							=					input("""Enter the second string """).strip()

							UpperCamelCase_							=					check_anagrams(input_a, input_b)
							print(f'''{input_a} and {input_b} are {'' if status else 'not '}anagrams.''')





