


"""simple docstring"""
import random
import unittest

import torch

from diffusers import IFInpaintingSuperResolutionPipeline
from diffusers.utils import floats_tensor
from diffusers.utils.import_utils import is_xformers_available
from diffusers.utils.testing_utils import skip_mps, torch_device

from ..pipeline_params import (
    TEXT_GUIDED_IMAGE_INPAINTING_BATCH_PARAMS,
    TEXT_GUIDED_IMAGE_INPAINTING_PARAMS,
)
from ..test_pipelines_common import PipelineTesterMixin
from . import IFPipelineTesterMixin




@skip_mps
class 	lowercase__				(					A_ ,A_ ,unittest.TestCase				):
   __UpperCAmelCase							       =					IFInpaintingSuperResolutionPipeline
   __UpperCAmelCase							       =					TEXT_GUIDED_IMAGE_INPAINTING_PARAMS - {'''width''', '''height'''}
   __UpperCAmelCase							       =					TEXT_GUIDED_IMAGE_INPAINTING_BATCH_PARAMS.union({'''original_image'''}				)
   __UpperCAmelCase							       =					PipelineTesterMixin.required_optional_params - {'''latents'''}





   def 		UpperCamelCase_  (							self)  ->  List[Any]:
      return self._get_superresolution_dummy_components()





   def 		UpperCamelCase_  (							self      ,   SCREAMING_SNAKE_CASE      ,   SCREAMING_SNAKE_CASE=0)  ->  Optional[Any]:
      if str(SCREAMING_SNAKE_CASE).startswith("""mps"""):
         _lowerCamelCase	:					str   =		torch.manual_seed(SCREAMING_SNAKE_CASE)
      else:
         _lowerCamelCase	:					List[Any]   =		torch.Generator(device=SCREAMING_SNAKE_CASE).manual_seed(SCREAMING_SNAKE_CASE)

      _lowerCamelCase	:					Optional[int]   =		floats_tensor((1, 3, 16, 16)      ,   rng=random.Random(SCREAMING_SNAKE_CASE)).to(SCREAMING_SNAKE_CASE)
      _lowerCamelCase	:					Optional[Any]   =		floats_tensor((1, 3, 32, 32)      ,   rng=random.Random(SCREAMING_SNAKE_CASE)).to(SCREAMING_SNAKE_CASE)
      _lowerCamelCase	:					int   =		floats_tensor((1, 3, 32, 32)      ,   rng=random.Random(SCREAMING_SNAKE_CASE)).to(SCREAMING_SNAKE_CASE)

      _lowerCamelCase	:					Dict   =		{
          """prompt""": """A painting of a squirrel eating a burger""",
          """image""": image,
          """original_image""": original_image,
          """mask_image""": mask_image,
          """generator""": generator,
          """num_inference_steps""": 2,
          """output_type""": """numpy""",
      }

      return inputs





   @unittest.skipIf(
       torch_device != """cuda""" or not is_xformers_available()      ,   reason="""XFormers attention is only available with CUDA and `xformers` installed"""      ,   )
   def 		UpperCamelCase_  (							self)  ->  Any:
      self._test_xformers_attention_forwardGenerator_pass(expected_max_diff=1e-3)





   def 		UpperCamelCase_  (							self)  ->  List[str]:
      self._test_save_load_optional_components()





   @unittest.skipIf(torch_device != """cuda"""      ,   reason="""float16 requires CUDA""")
   def 		UpperCamelCase_  (							self)  ->  str:
      # Due to non-determinism in save load of the hf-internal-testing/tiny-random-t5 text encoder
      super().test_save_load_floataa(expected_max_diff=1e-1)





   def 		UpperCamelCase_  (							self)  ->  Optional[int]:
      self._test_attention_slicing_forward_pass(expected_max_diff=1e-2)





   def 		UpperCamelCase_  (							self)  ->  Dict:
      self._test_save_load_local()





   def 		UpperCamelCase_  (							self)  ->  int:
      self._test_inference_batch_single_identical(
          expected_max_diff=1e-2      ,   )





"""simple docstring"""
from collections import defaultdict

def 				_snake_case      (   __snake_case							:      str						, __snake_case							:      str   ):




   """simple docstring"""







   _lowerCamelCase	:					Tuple   =		first_str.lower().strip()
   _lowerCamelCase	:					int   =		second_str.lower().strip()

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

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

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

   # For each character in input strings,
   # increment count in the corresponding
   for i in range(len(__snake_case   )   ):
      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.''')

