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




		"""simple docstring"""





		__lowercase							:  Optional[Any]						   =		MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING
		__lowercase							:  Any						   =		TF_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING




		def 	snake_case_     (     self							,  lowerCAmelCase__							,  lowerCAmelCase__							,  lowerCAmelCase__):
				__SCREAMING_SNAKE_CASE            = TextaTextGenerationPipeline(model=lowerCAmelCase__							,  tokenizer=lowerCAmelCase__)
				return generator, ["Something to write", "Something else"]




		def 	snake_case_     (     self							,  lowerCAmelCase__							,  lowerCAmelCase__):
				__SCREAMING_SNAKE_CASE            = generator("""Something there""")
				self.assertEqual(lowerCAmelCase__							,  [{"""generated_text""": ANY(lowerCAmelCase__)}])
				# These are encoder decoder, they don't just append to incoming string
				self.assertFalse(outputs[0]["""generated_text"""].startswith("""Something there"""))

				__SCREAMING_SNAKE_CASE            = generator(["""This is great !""", """Something else"""]							,  num_return_sequences=2							,  do_sample=lowerCAmelCase__)
				self.assertEqual(
				    lowerCAmelCase__							,  [
				        [{"""generated_text""": ANY(lowerCAmelCase__)}, {"""generated_text""": ANY(lowerCAmelCase__)}],
				        [{"""generated_text""": ANY(lowerCAmelCase__)}, {"""generated_text""": ANY(lowerCAmelCase__)}],
				    ]							,  )

				__SCREAMING_SNAKE_CASE            = generator(
				    ["""This is great !""", """Something else"""]							,  num_return_sequences=2							,  batch_size=2							,  do_sample=lowerCAmelCase__)
				self.assertEqual(
				    lowerCAmelCase__							,  [
				        [{"""generated_text""": ANY(lowerCAmelCase__)}, {"""generated_text""": ANY(lowerCAmelCase__)}],
				        [{"""generated_text""": ANY(lowerCAmelCase__)}, {"""generated_text""": ANY(lowerCAmelCase__)}],
				    ]							,  )

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




		@require_torch
		def 	snake_case_     (     self):
				__SCREAMING_SNAKE_CASE            = pipeline("""text2text-generation"""							,  model="""patrickvonplaten/t5-tiny-random"""							,  framework="""pt""")
				# do_sample=False necessary for reproducibility
				__SCREAMING_SNAKE_CASE            = generator("""Something there"""							,  do_sample=lowerCAmelCase__)
				self.assertEqual(lowerCAmelCase__							,  [{"""generated_text""": """"""}])

				__SCREAMING_SNAKE_CASE            = 3
				__SCREAMING_SNAKE_CASE            = generator(
				    """Something there"""							,  num_return_sequences=lowerCAmelCase__							,  num_beams=lowerCAmelCase__							,  )
				__SCREAMING_SNAKE_CASE            = [
				    {"""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(lowerCAmelCase__							,  lowerCAmelCase__)

				__SCREAMING_SNAKE_CASE            = generator("""This is a test"""							,  do_sample=lowerCAmelCase__							,  num_return_sequences=2							,  return_tensors=lowerCAmelCase__)
				self.assertEqual(
				    lowerCAmelCase__							,  [
				        {"""generated_token_ids""": ANY(torch.Tensor)},
				        {"""generated_token_ids""": ANY(torch.Tensor)},
				    ]							,  )
				__SCREAMING_SNAKE_CASE            = generator.model.config.eos_token_id
				__SCREAMING_SNAKE_CASE            = """<pad>"""
				__SCREAMING_SNAKE_CASE            = generator(
				    ["""This is a test""", """This is a second test"""]							,  do_sample=lowerCAmelCase__							,  num_return_sequences=2							,  batch_size=2							,  return_tensors=lowerCAmelCase__							,  )
				self.assertEqual(
				    lowerCAmelCase__							,  [
				        [
				            {"""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 	snake_case_     (     self):
				__SCREAMING_SNAKE_CASE            = pipeline("""text2text-generation"""							,  model="""patrickvonplaten/t5-tiny-random"""							,  framework="""tf""")
				# do_sample=False necessary for reproducibility
				__SCREAMING_SNAKE_CASE            = generator("""Something there"""							,  do_sample=lowerCAmelCase__)
				self.assertEqual(lowerCAmelCase__							,  [{"""generated_text""": """"""}])






"""simple docstring"""





from collections import defaultdict



def 						_lowerCAmelCase				(				UpperCamelCase_  ,				UpperCamelCase_				):
		__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(UpperCamelCase_				) != len(UpperCamelCase_				):
				return False

		# Default values for count should be 0
		__SCREAMING_SNAKE_CASE            = defaultdict(UpperCamelCase_				)

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

							__magic_name__       =			check_anagrams(input_a, input_b)
							print(F"""{input_a} and {input_b} are {"" if status else "not "}anagrams.""")




