




import unittest

import numpy as np

from transformers.testing_utils import require_flax, require_tf, require_torch
from transformers.utils import (
    expand_dims,
    flatten_dict,
    is_flax_available,
    is_tf_available,
    is_torch_available,
    reshape,
    squeeze,
    transpose,
)


if is_flax_available():
       import jax.numpy as jnp

if is_tf_available():
       import tensorflow as tf

if is_torch_available():
       import torch




class 						__lowercase		(unittest.TestCase							):




      """simple docstring"""





      def      UpperCAmelCase				(				self     )		->    List[str]:
         snake_case				:    Optional[Any]           =	{
             """task_specific_params""": {
                 """summarization""": {"""length_penalty""": 1.0, """max_length""": 1_2_8, """min_length""": 1_2, """num_beams""": 4},
                 """summarization_cnn""": {"""length_penalty""": 2.0, """max_length""": 1_4_2, """min_length""": 5_6, """num_beams""": 4},
                 """summarization_xsum""": {"""length_penalty""": 1.0, """max_length""": 6_2, """min_length""": 1_1, """num_beams""": 6},
             }
         }
         snake_case				:    int           =	{
             """task_specific_params.summarization.length_penalty""": 1.0,
             """task_specific_params.summarization.max_length""": 1_2_8,
             """task_specific_params.summarization.min_length""": 1_2,
             """task_specific_params.summarization.num_beams""": 4,
             """task_specific_params.summarization_cnn.length_penalty""": 2.0,
             """task_specific_params.summarization_cnn.max_length""": 1_4_2,
             """task_specific_params.summarization_cnn.min_length""": 5_6,
             """task_specific_params.summarization_cnn.num_beams""": 4,
             """task_specific_params.summarization_xsum.length_penalty""": 1.0,
             """task_specific_params.summarization_xsum.max_length""": 6_2,
             """task_specific_params.summarization_xsum.min_length""": 1_1,
             """task_specific_params.summarization_xsum.num_beams""": 6,
         }

         self.assertEqual(flatten_dict(A     )    ,				A     )

      def      UpperCAmelCase				(				self     )		->    int:
         snake_case				:    List[Any]           =	np.random.randn(3    ,				4     )
         self.assertTrue(np.allclose(transpose(A     )    ,				x.transpose()     )     )

         snake_case				:    Optional[Any]           =	np.random.randn(3    ,				4    ,				5     )
         self.assertTrue(np.allclose(transpose(A    ,				axes=(1, 2, 0)     )    ,				x.transpose((1, 2, 0)     )     )     )

      @require_torch
      def      UpperCAmelCase				(				self     )		->    int:
         snake_case				:    List[Any]           =	np.random.randn(3    ,				4     )
         snake_case				:    List[Any]           =	torch.tensor(A     )
         self.assertTrue(np.allclose(transpose(A     )    ,				transpose(A     ).numpy()     )     )

         snake_case				:    Union[str, Any]           =	np.random.randn(3    ,				4    ,				5     )
         snake_case				:    List[str]           =	torch.tensor(A     )
         self.assertTrue(np.allclose(transpose(A    ,				axes=(1, 2, 0)     )    ,				transpose(A    ,				axes=(1, 2, 0)     ).numpy()     )     )

      @require_tf
      def      UpperCAmelCase				(				self     )		->    str:
         snake_case				:    Union[str, Any]           =	np.random.randn(3    ,				4     )
         snake_case				:    Tuple           =	tf.constant(A     )
         self.assertTrue(np.allclose(transpose(A     )    ,				transpose(A     ).numpy()     )     )

         snake_case				:    Tuple           =	np.random.randn(3    ,				4    ,				5     )
         snake_case				:    Union[str, Any]           =	tf.constant(A     )
         self.assertTrue(np.allclose(transpose(A    ,				axes=(1, 2, 0)     )    ,				transpose(A    ,				axes=(1, 2, 0)     ).numpy()     )     )

      @require_flax
      def      UpperCAmelCase				(				self     )		->    int:
         snake_case				:    Dict           =	np.random.randn(3    ,				4     )
         snake_case				:    Union[str, Any]           =	jnp.array(A     )
         self.assertTrue(np.allclose(transpose(A     )    ,				np.asarray(transpose(A     )     )     )     )

         snake_case				:    Optional[Any]           =	np.random.randn(3    ,				4    ,				5     )
         snake_case				:    Any           =	jnp.array(A     )
         self.assertTrue(np.allclose(transpose(A    ,				axes=(1, 2, 0)     )    ,				np.asarray(transpose(A    ,				axes=(1, 2, 0)     )     )     )     )

      def      UpperCAmelCase				(				self     )		->    Dict:
         snake_case				:    List[str]           =	np.random.randn(3    ,				4     )
         self.assertTrue(np.allclose(reshape(A    ,				(4, 3)     )    ,				np.reshape(A    ,				(4, 3)     )     )     )

         snake_case				:    int           =	np.random.randn(3    ,				4    ,				5     )
         self.assertTrue(np.allclose(reshape(A    ,				(1_2, 5)     )    ,				np.reshape(A    ,				(1_2, 5)     )     )     )

      @require_torch
      def      UpperCAmelCase				(				self     )		->    Dict:
         snake_case				:    Optional[int]           =	np.random.randn(3    ,				4     )
         snake_case				:    int           =	torch.tensor(A     )
         self.assertTrue(np.allclose(reshape(A    ,				(4, 3)     )    ,				reshape(A    ,				(4, 3)     ).numpy()     )     )

         snake_case				:    Union[str, Any]           =	np.random.randn(3    ,				4    ,				5     )
         snake_case				:    int           =	torch.tensor(A     )
         self.assertTrue(np.allclose(reshape(A    ,				(1_2, 5)     )    ,				reshape(A    ,				(1_2, 5)     ).numpy()     )     )

      @require_tf
      def      UpperCAmelCase				(				self     )		->    Tuple:
         snake_case				:    Dict           =	np.random.randn(3    ,				4     )
         snake_case				:    Dict           =	tf.constant(A     )
         self.assertTrue(np.allclose(reshape(A    ,				(4, 3)     )    ,				reshape(A    ,				(4, 3)     ).numpy()     )     )

         snake_case				:    int           =	np.random.randn(3    ,				4    ,				5     )
         snake_case				:    str           =	tf.constant(A     )
         self.assertTrue(np.allclose(reshape(A    ,				(1_2, 5)     )    ,				reshape(A    ,				(1_2, 5)     ).numpy()     )     )

      @require_flax
      def      UpperCAmelCase				(				self     )		->    Optional[Any]:
         snake_case				:    Tuple           =	np.random.randn(3    ,				4     )
         snake_case				:    str           =	jnp.array(A     )
         self.assertTrue(np.allclose(reshape(A    ,				(4, 3)     )    ,				np.asarray(reshape(A    ,				(4, 3)     )     )     )     )

         snake_case				:    int           =	np.random.randn(3    ,				4    ,				5     )
         snake_case				:    List[Any]           =	jnp.array(A     )
         self.assertTrue(np.allclose(reshape(A    ,				(1_2, 5)     )    ,				np.asarray(reshape(A    ,				(1_2, 5)     )     )     )     )

      def      UpperCAmelCase				(				self     )		->    Optional[Any]:
         snake_case				:    Union[str, Any]           =	np.random.randn(1    ,				3    ,				4     )
         self.assertTrue(np.allclose(squeeze(A     )    ,				np.squeeze(A     )     )     )

         snake_case				:    Optional[Any]           =	np.random.randn(1    ,				4    ,				1    ,				5     )
         self.assertTrue(np.allclose(squeeze(A    ,				axis=2     )    ,				np.squeeze(A    ,				axis=2     )     )     )

      @require_torch
      def      UpperCAmelCase				(				self     )		->    Optional[int]:
         snake_case				:    str           =	np.random.randn(1    ,				3    ,				4     )
         snake_case				:    Union[str, Any]           =	torch.tensor(A     )
         self.assertTrue(np.allclose(squeeze(A     )    ,				squeeze(A     ).numpy()     )     )

         snake_case				:    List[Any]           =	np.random.randn(1    ,				4    ,				1    ,				5     )
         snake_case				:    List[str]           =	torch.tensor(A     )
         self.assertTrue(np.allclose(squeeze(A    ,				axis=2     )    ,				squeeze(A    ,				axis=2     ).numpy()     )     )

      @require_tf
      def      UpperCAmelCase				(				self     )		->    Union[str, Any]:
         snake_case				:    Tuple           =	np.random.randn(1    ,				3    ,				4     )
         snake_case				:    int           =	tf.constant(A     )
         self.assertTrue(np.allclose(squeeze(A     )    ,				squeeze(A     ).numpy()     )     )

         snake_case				:    Tuple           =	np.random.randn(1    ,				4    ,				1    ,				5     )
         snake_case				:    str           =	tf.constant(A     )
         self.assertTrue(np.allclose(squeeze(A    ,				axis=2     )    ,				squeeze(A    ,				axis=2     ).numpy()     )     )

      @require_flax
      def      UpperCAmelCase				(				self     )		->    str:
         snake_case				:    List[Any]           =	np.random.randn(1    ,				3    ,				4     )
         snake_case				:    str           =	jnp.array(A     )
         self.assertTrue(np.allclose(squeeze(A     )    ,				np.asarray(squeeze(A     )     )     )     )

         snake_case				:    Tuple           =	np.random.randn(1    ,				4    ,				1    ,				5     )
         snake_case				:    List[str]           =	jnp.array(A     )
         self.assertTrue(np.allclose(squeeze(A    ,				axis=2     )    ,				np.asarray(squeeze(A    ,				axis=2     )     )     )     )

      def      UpperCAmelCase				(				self     )		->    Tuple:
         snake_case				:    Union[str, Any]           =	np.random.randn(3    ,				4     )
         self.assertTrue(np.allclose(expand_dims(A    ,				axis=1     )    ,				np.expand_dims(A    ,				axis=1     )     )     )

      @require_torch
      def      UpperCAmelCase				(				self     )		->    str:
         snake_case				:    Dict           =	np.random.randn(3    ,				4     )
         snake_case				:    Any           =	torch.tensor(A     )
         self.assertTrue(np.allclose(expand_dims(A    ,				axis=1     )    ,				expand_dims(A    ,				axis=1     ).numpy()     )     )

      @require_tf
      def      UpperCAmelCase				(				self     )		->    Optional[Any]:
         snake_case				:    Any           =	np.random.randn(3    ,				4     )
         snake_case				:    List[Any]           =	tf.constant(A     )
         self.assertTrue(np.allclose(expand_dims(A    ,				axis=1     )    ,				expand_dims(A    ,				axis=1     ).numpy()     )     )

      @require_flax
      def      UpperCAmelCase				(				self     )		->    Dict:
         snake_case				:    Any           =	np.random.randn(3    ,				4     )
         snake_case				:    Tuple           =	jnp.array(A     )
         self.assertTrue(np.allclose(expand_dims(A    ,				axis=1     )    ,				np.asarray(expand_dims(A    ,				axis=1     )     )     )     )











from collections import defaultdict




def 						SCREAMING_SNAKE_CASE__ (   lowercase						,lowercase					)  ->       bool:
   snake_case				:    List[str]           =	first_str.lower().strip()
   snake_case				:    List[str]           =	second_str.lower().strip()

   # Remove whitespace
   snake_case				:    Any           =	first_str.replace(""" """						,""""""					)
   snake_case				:    List[str]           =	second_str.replace(""" """						,""""""					)

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

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

   # For each character in input strings,
   # increment count in the corresponding
   for i in range(len(lowercase					)					):
      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()
       lowerCamelCase	:	List[Any]				=   input('Enter the first string ').strip()
       lowerCamelCase	:	Optional[int]				=   input('Enter the second string ').strip()

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





