




'''simple docstring'''






import unittest

import numpy as np
import requests

from transformers.testing_utils import require_torch, require_vision
from transformers.utils import is_torch_available, is_vision_available

from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs


if is_torch_available():
      import torch

      from transformers.pytorch_utils import is_torch_greater_or_equal_than_1_11
else:
      A_			      =		False

if is_vision_available():
      from PIL import Image

      from transformers import PixaStructImageProcessor






class        lowercase_      (						unittest.TestCase							):





     def __init__(     self     :					Any     ,							__lowerCamelCase     :					str     ,							__lowerCamelCase     :					Union[str, Any]=7     ,							__lowerCamelCase     :					Dict=3     ,							__lowerCamelCase     :					int=18     ,							__lowerCamelCase     :					List[str]=30     ,							__lowerCamelCase     :					List[str]=400     ,							__lowerCamelCase     :					Any=None     ,							__lowerCamelCase     :					Any=True     ,							__lowerCamelCase     :					Optional[Any]=True     ,							__lowerCamelCase     :					Optional[int]=None     ,							):
           snake_case__       :   Union[str, Any]	      =    size if size is not None else {'height': 20, 'width': 20}
           snake_case__       :   Dict	      =    parent
           snake_case__       :   Any	      =    batch_size
           snake_case__       :   int	      =    num_channels
           snake_case__       :   Tuple	      =    image_size
           snake_case__       :   Optional[int]	      =    min_resolution
           snake_case__       :   Dict	      =    max_resolution
           snake_case__       :   Union[str, Any]	      =    size
           snake_case__       :   List[Any]	      =    do_normalize
           snake_case__       :   List[Any]	      =    do_convert_rgb
           snake_case__       :   Tuple	      =    [512, 1024, 2048, 4096]
           snake_case__       :   Union[str, Any]	      =    patch_size if patch_size is not None else {'height': 16, 'width': 16}





     def 			_lowerCAmelCase      (     self     :					List[str]			):
           return {"do_normalize": self.do_normalize, "do_convert_rgb": self.do_convert_rgb}





     def 			_lowerCAmelCase      (     self     :					Union[str, Any]			):
           snake_case__       :   Optional[Any]	      =    'https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/australia.jpg'
           snake_case__       :   str	      =    Image.open(requests.get(__lowerCAmelCase     ,							stream=__lowerCAmelCase			).raw			).convert('RGB'			)
           return raw_image






@unittest.skipIf(
    not is_torch_greater_or_equal_than_1_11						,       reason="`Pix2StructImageProcessor` requires `torch>=1.11.0`."						,       )
@require_torch
@require_vision
class        lowercase_      (						UpperCAmelCase__						,       unittest.TestCase							):
     A_											=			PixaStructImageProcessor if is_vision_available() else None





     def 			_lowerCAmelCase      (     self     :					List[Any]			):
           snake_case__       :   List[str]	      =    PixaStructImageProcessingTester(self			)





     @property
     def 			_lowerCAmelCase      (     self     :					int			):
           return self.image_processor_tester.prepare_image_processor_dict()





     def 			_lowerCAmelCase      (     self     :					Union[str, Any]			):
           snake_case__       :   Dict	      =    self.image_processing_class(**self.image_processor_dict			)
           self.assertTrue(hasattr(__lowerCAmelCase     ,							'do_normalize'			)			)
           self.assertTrue(hasattr(__lowerCAmelCase     ,							'do_convert_rgb'			)			)





     def 			_lowerCAmelCase      (     self     :					List[Any]			):
           snake_case__       :   Any	      =    self.image_processor_tester.prepare_dummy_image()

           snake_case__       :   Tuple	      =    self.image_processing_class(**self.image_processor_dict			)
           snake_case__       :   str	      =    2048

           snake_case__       :   Dict	      =    image_processor(__lowerCAmelCase     ,							return_tensors='pt'     ,							max_patches=__lowerCAmelCase			)
           self.assertTrue(torch.allclose(inputs.flattened_patches.mean()     ,							torch.tensor(0.0_6_0_6			)     ,							atol=1E-3     ,							rtol=1E-3			)			)





     def 			_lowerCAmelCase      (     self     :					Union[str, Any]			):
           # Initialize image_processor
           snake_case__       :   Tuple	      =    self.image_processing_class(**self.image_processor_dict			)
           # create random PIL images
           snake_case__       :   Optional[Any]	      =    prepare_image_inputs(self.image_processor_tester     ,							equal_resolution=__lowerCAmelCase			)
           for image in image_inputs:
                 self.assertIsInstance(__lowerCAmelCase     ,							Image.Image			)

           # Test not batched input
           snake_case__       :   Optional[Any]	      =    (
               (self.image_processor_tester.patch_size['height'] * self.image_processor_tester.patch_size['width'])
               * self.image_processor_tester.num_channels
           ) + 2

           for max_patch in self.image_processor_tester.max_patches:
                 # Test not batched input
                 snake_case__       :   str	      =    image_processor(
                     image_inputs[0]     ,							return_tensors='pt'     ,							max_patches=__lowerCAmelCase			).flattened_patches
                 self.assertEqual(
                     encoded_images.shape     ,							(1, max_patch, expected_hidden_dim)     ,							)

                 # Test batched
                 snake_case__       :   Any	      =    image_processor(
                     __lowerCAmelCase     ,							return_tensors='pt'     ,							max_patches=__lowerCAmelCase			).flattened_patches
                 self.assertEqual(
                     encoded_images.shape     ,							(self.image_processor_tester.batch_size, max_patch, expected_hidden_dim)     ,							)





     def 			_lowerCAmelCase      (     self     :					Optional[int]			):
           # Initialize image_processor
           snake_case__       :   Dict	      =    self.image_processing_class(**self.image_processor_dict			)
           # create random PIL images
           snake_case__       :   Any	      =    prepare_image_inputs(self.image_processor_tester     ,							equal_resolution=__lowerCAmelCase			)
           for image in image_inputs:
                 self.assertIsInstance(__lowerCAmelCase     ,							Image.Image			)

           # Test not batched input
           snake_case__       :   str	      =    (
               (self.image_processor_tester.patch_size['height'] * self.image_processor_tester.patch_size['width'])
               * self.image_processor_tester.num_channels
           ) + 2

           snake_case__       :   Union[str, Any]	      =    True

           for max_patch in self.image_processor_tester.max_patches:
                 # Test not batched input
                 with self.assertRaises(__lowerCAmelCase			):
                       snake_case__       :   List[Any]	      =    image_processor(
                           image_inputs[0]     ,							return_tensors='pt'     ,							max_patches=__lowerCAmelCase			).flattened_patches

                 snake_case__       :   Dict	      =    'Hello'

                 snake_case__       :   Dict	      =    image_processor(
                     image_inputs[0]     ,							return_tensors='pt'     ,							max_patches=__lowerCAmelCase     ,							header_text=__lowerCAmelCase			).flattened_patches
                 self.assertEqual(
                     encoded_images.shape     ,							(1, max_patch, expected_hidden_dim)     ,							)

                 # Test batched
                 snake_case__       :   Optional[int]	      =    image_processor(
                     __lowerCAmelCase     ,							return_tensors='pt'     ,							max_patches=__lowerCAmelCase     ,							header_text=__lowerCAmelCase			).flattened_patches
                 self.assertEqual(
                     encoded_images.shape     ,							(self.image_processor_tester.batch_size, max_patch, expected_hidden_dim)     ,							)





     def 			_lowerCAmelCase      (     self     :					Any			):
           # Initialize image_processor
           snake_case__       :   Union[str, Any]	      =    self.image_processing_class(**self.image_processor_dict			)
           # create random numpy tensors
           snake_case__       :   Optional[Any]	      =    prepare_image_inputs(self.image_processor_tester     ,							equal_resolution=__lowerCAmelCase     ,							numpify=__lowerCAmelCase			)
           for image in image_inputs:
                 self.assertIsInstance(__lowerCAmelCase     ,							np.ndarray			)

           snake_case__       :   Optional[int]	      =    (
               (self.image_processor_tester.patch_size['height'] * self.image_processor_tester.patch_size['width'])
               * self.image_processor_tester.num_channels
           ) + 2

           for max_patch in self.image_processor_tester.max_patches:
                 # Test not batched input
                 snake_case__       :   int	      =    image_processor(
                     image_inputs[0]     ,							return_tensors='pt'     ,							max_patches=__lowerCAmelCase			).flattened_patches
                 self.assertEqual(
                     encoded_images.shape     ,							(1, max_patch, expected_hidden_dim)     ,							)

                 # Test batched
                 snake_case__       :   Optional[Any]	      =    image_processor(
                     __lowerCAmelCase     ,							return_tensors='pt'     ,							max_patches=__lowerCAmelCase			).flattened_patches
                 self.assertEqual(
                     encoded_images.shape     ,							(self.image_processor_tester.batch_size, max_patch, expected_hidden_dim)     ,							)





     def 			_lowerCAmelCase      (     self     :					Union[str, Any]			):
           # Initialize image_processor
           snake_case__       :   Optional[int]	      =    self.image_processing_class(**self.image_processor_dict			)
           # create random PyTorch tensors
           snake_case__       :   List[str]	      =    prepare_image_inputs(self.image_processor_tester     ,							equal_resolution=__lowerCAmelCase     ,							torchify=__lowerCAmelCase			)
           for image in image_inputs:
                 self.assertIsInstance(__lowerCAmelCase     ,							torch.Tensor			)

           # Test not batched input
           snake_case__       :   Optional[int]	      =    (
               (self.image_processor_tester.patch_size['height'] * self.image_processor_tester.patch_size['width'])
               * self.image_processor_tester.num_channels
           ) + 2

           for max_patch in self.image_processor_tester.max_patches:
                 # Test not batched input
                 snake_case__       :   List[Any]	      =    image_processor(
                     image_inputs[0]     ,							return_tensors='pt'     ,							max_patches=__lowerCAmelCase			).flattened_patches
                 self.assertEqual(
                     encoded_images.shape     ,							(1, max_patch, expected_hidden_dim)     ,							)

                 # Test batched
                 snake_case__       :   Union[str, Any]	      =    image_processor(
                     __lowerCAmelCase     ,							return_tensors='pt'     ,							max_patches=__lowerCAmelCase			).flattened_patches
                 self.assertEqual(
                     encoded_images.shape     ,							(self.image_processor_tester.batch_size, max_patch, expected_hidden_dim)     ,							)






@unittest.skipIf(
    not is_torch_greater_or_equal_than_1_11						,       reason="`Pix2StructImageProcessor` requires `torch>=1.11.0`."						,       )
@require_torch
@require_vision
class        lowercase_      (						UpperCAmelCase__						,       unittest.TestCase							):
     A_											=			PixaStructImageProcessor if is_vision_available() else None





     def 			_lowerCAmelCase      (     self     :					Any			):
           snake_case__       :   Dict	      =    PixaStructImageProcessingTester(self     ,							num_channels=4			)
           snake_case__       :   str	      =    3





     @property
     def 			_lowerCAmelCase      (     self     :					Any			):
           return self.image_processor_tester.prepare_image_processor_dict()





     def 			_lowerCAmelCase      (     self     :					Tuple			):
           snake_case__       :   Dict	      =    self.image_processing_class(**self.image_processor_dict			)
           self.assertTrue(hasattr(__lowerCAmelCase     ,							'do_normalize'			)			)
           self.assertTrue(hasattr(__lowerCAmelCase     ,							'do_convert_rgb'			)			)





     def 			_lowerCAmelCase      (     self     :					Optional[Any]			):
           # Initialize image_processor
           snake_case__       :   Dict	      =    self.image_processing_class(**self.image_processor_dict			)
           # create random PIL images
           snake_case__       :   int	      =    prepare_image_inputs(self.image_processor_tester     ,							equal_resolution=__lowerCAmelCase			)
           for image in image_inputs:
                 self.assertIsInstance(__lowerCAmelCase     ,							Image.Image			)

           # Test not batched input
           snake_case__       :   str	      =    (
               (self.image_processor_tester.patch_size['height'] * self.image_processor_tester.patch_size['width'])
               * (self.image_processor_tester.num_channels - 1)
           ) + 2

           for max_patch in self.image_processor_tester.max_patches:
                 # Test not batched input
                 snake_case__       :   Union[str, Any]	      =    image_processor(
                     image_inputs[0]     ,							return_tensors='pt'     ,							max_patches=__lowerCAmelCase			).flattened_patches
                 self.assertEqual(
                     encoded_images.shape     ,							(1, max_patch, expected_hidden_dim)     ,							)

                 # Test batched
                 snake_case__       :   Union[str, Any]	      =    image_processor(
                     __lowerCAmelCase     ,							return_tensors='pt'     ,							max_patches=__lowerCAmelCase			).flattened_patches
                 self.assertEqual(
                     encoded_images.shape     ,							(self.image_processor_tester.batch_size, max_patch, expected_hidden_dim)     ,							)






'''simple docstring'''


from collections import defaultdict
def 						lowerCamelCase__   (				a    ,	a							):
						__snake_case						 =   first_str.lower().strip()
						__snake_case						 =   second_str.lower().strip()

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

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

						# Default values for count should be 0
						__snake_case						 =   defaultdict(a							)

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

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

