
import random
import unittest

import torch

from diffusers import IFImgaImgPipeline
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	(		snake_case__ ,snake_case__ ,unittest.TestCase				):
   A__      :	List[Any]		  =  IFImgaImgPipeline
   A__      :	List[Any]		  =  TEXT_GUIDED_IMAGE_VARIATION_PARAMS - {"width", "height"}
   A__      :	List[Any]		  =  TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS
   A__      :	Any		  =  PipelineTesterMixin.required_optional_params - {"latents"}



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


          '''simple docstring'''


          return self._get_dummy_components()



   def        _SCREAMING_SNAKE_CASE     (self	:      Dict					,		snake_case__	:      Tuple					,		snake_case__	:      Optional[Any]=0				)	->			List[str]:


          '''simple docstring'''


          if str(__snake_case				).startswith("mps"				):
                 snake_case :     Optional[Any]           =   torch.manual_seed(__snake_case				)
          else:
                 snake_case :     Optional[Any]           =   torch.Generator(device=__snake_case				).manual_seed(__snake_case				)

          snake_case :     Dict           =   floats_tensor((1, 3, 32, 32)					,		rng=random.Random(__snake_case				)				).to(__snake_case				)

          snake_case :     Optional[Any]           =   {
              "prompt": "A painting of a squirrel eating a burger",
              "image": image,
              "generator": generator,
              "num_inference_steps": 2,
              "output_type": "numpy",
          }

          return inputs



   def        _SCREAMING_SNAKE_CASE     (self	:      Tuple				)	->			Any:


          '''simple docstring'''


          self._test_save_load_optional_components()



   @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	:      List[Any]				)	->			str:


          '''simple docstring'''


          self._test_xformers_attention_forwardGenerator_pass(expected_max_diff=1e-3				)



   @unittest.skipIf(torch_device != "cuda"					,		reason="float16 requires CUDA"				)
   def        _SCREAMING_SNAKE_CASE     (self	:      List[str]				)	->			int:


          '''simple docstring'''


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



   @unittest.skipIf(torch_device != "cuda"					,		reason="float16 requires CUDA"				)
   def        _SCREAMING_SNAKE_CASE     (self	:      List[str]				)	->			Optional[int]:


          '''simple docstring'''


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



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


          '''simple docstring'''


          self._test_attention_slicing_forward_pass(expected_max_diff=1e-2				)



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


          '''simple docstring'''


          self._test_save_load_local()



   def        _SCREAMING_SNAKE_CASE     (self	:      Optional[Any]				)	->			Optional[Any]:


          '''simple docstring'''


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







def     UpperCamelCase      (					__lowerCamelCase  :				int = 998001					):
       snake_case :     Optional[Any]           =   0
       for i in range(999       ,      99       ,      -1					):  # 3 digit numbers range from 999 down to 100
              for j in range(999       ,      99       ,      -1					):
                     snake_case :     Tuple           =   str(i * j					)
                     if product_string == product_string[::-1] and i * j < n:
                            snake_case :     str           =   max(__lowerCamelCase       ,      i * j					)
       return answer


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





