





import random
import unittest

import torch

from diffusers import IFImgaImgSuperResolutionPipeline
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_VARIATION_BATCH_PARAMS, TEXT_GUIDED_IMAGE_VARIATION_PARAMS
from ..test_pipelines_common import PipelineTesterMixin
from . import IFPipelineTesterMixin

@skip_mps
class 		UpperCamelCase__			(				A__							,				A__							,				unittest.TestCase       ):



     '''simple docstring'''

     __snake_case   :     List[Any]		     =      IFImgaImgSuperResolutionPipeline
     __snake_case   :     Any		     =      TEXT_GUIDED_IMAGE_VARIATION_PARAMS - {"width", "height"}
     __snake_case   :     Tuple		     =      TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS.union({"original_image"}       )
     __snake_case   :     int		     =      PipelineTesterMixin.required_optional_params - {"latents"}






     def     SCREAMING_SNAKE_CASE__  (							self						:   Union[str, Any]	)					->		List[str]:




           '''simple docstring'''


           return self._get_superresolution_dummy_components()






     def     SCREAMING_SNAKE_CASE__  (							self						:   Tuple						,lowerCamelCase__						:   List[str]						,lowerCamelCase__						:   Optional[Any]=0	)					->		Optional[int]:




           '''simple docstring'''


           if str(__A	).startswith("""mps"""	):
                 SCREAMING_SNAKE_CASE		=						torch.manual_seed(__A	)
           else:
                 SCREAMING_SNAKE_CASE		=						torch.Generator(device=__A	).manual_seed(__A	)

           SCREAMING_SNAKE_CASE		=						floats_tensor((1, 3, 32, 32)						,rng=random.Random(__A	)	).to(__A	)
           SCREAMING_SNAKE_CASE		=						floats_tensor((1, 3, 16, 16)						,rng=random.Random(__A	)	).to(__A	)

           SCREAMING_SNAKE_CASE		=						{
               """prompt""": """A painting of a squirrel eating a burger""",
               """image""": image,
               """original_image""": original_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     SCREAMING_SNAKE_CASE__  (							self						:   Optional[Any]	)					->		Dict:




           '''simple docstring'''


           self._test_xformers_attention_forwardGenerator_pass(expected_max_diff=1e-3	)






     def     SCREAMING_SNAKE_CASE__  (							self						:   Dict	)					->		Tuple:




           '''simple docstring'''


           self._test_save_load_optional_components()






     @unittest.skipIf(torch_device != """cuda"""						,reason="""float16 requires CUDA"""	)
     def     SCREAMING_SNAKE_CASE__  (							self						:   Dict	)					->		Any:




           '''simple docstring'''


           super().test_save_load_floataa(expected_max_diff=1e-1	)






     def     SCREAMING_SNAKE_CASE__  (							self						:   str	)					->		str:




           '''simple docstring'''


           self._test_attention_slicing_forward_pass(expected_max_diff=1e-2	)






     def     SCREAMING_SNAKE_CASE__  (							self						:   Tuple	)					->		Dict:




           '''simple docstring'''


           self._test_save_load_local()






     def     SCREAMING_SNAKE_CASE__  (							self						:   Optional[int]	)					->		Union[str, Any]:




           '''simple docstring'''


           self._test_inference_batch_single_identical(
               expected_max_diff=1e-2						,)









from itertools import permutations



def        __lowercase       (				_SCREAMING_SNAKE_CASE     )			->       bool:


      '''simple docstring'''


      if num[3] % 2 != 0:
            return False

      if (num[2] + num[3] + num[4]) % 3 != 0:
            return False

      if num[5] % 5 != 0:
            return False

      SCREAMING_SNAKE_CASE		=						[7, 11, 13, 17]
      for i, test in enumerate(_SCREAMING_SNAKE_CASE     ):
            if (num[i + 4] * 1_00 + num[i + 5] * 10 + num[i + 6]) % test != 0:
                  return False
      return True



def        __lowercase       (				_SCREAMING_SNAKE_CASE = 10     )			->       int:


      '''simple docstring'''


      return sum(
          int("""""".join(map(_SCREAMING_SNAKE_CASE			,						_SCREAMING_SNAKE_CASE     )     )     )
          for num in permutations(range(_SCREAMING_SNAKE_CASE     )     )
          if is_substring_divisible(_SCREAMING_SNAKE_CASE     )     )


if __name__ == "__main__":
      print(F'''{solution() = }''')


