


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 						__a (							UpperCAmelCase       , UpperCAmelCase       , unittest.TestCase     ):
		_a      :    str           =      IFImgaImgSuperResolutionPipeline
		_a      :    Dict           =      TEXT_GUIDED_IMAGE_VARIATION_PARAMS - {"width", "height"}
		_a      :    Any           =      TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS.union({'original_image'}     )
		_a      :    str           =      PipelineTesterMixin.required_optional_params - {"latents"}
		def       UpperCAmelCase__							(     self		)					->			Dict:




									"""simple docstring"""





									return self._get_superresolution_dummy_components()
		def       UpperCAmelCase__							(     self     ,       _SCREAMING_SNAKE_CASE     ,       _SCREAMING_SNAKE_CASE=0		)					->			str:




									"""simple docstring"""





									if str(_SCREAMING_SNAKE_CASE		).startswith('mps'		):
																_UpperCAmelCase											=     torch.manual_seed(_SCREAMING_SNAKE_CASE		)
									else:
																_UpperCAmelCase											=     torch.Generator(device=_SCREAMING_SNAKE_CASE		).manual_seed(_SCREAMING_SNAKE_CASE		)

									_UpperCAmelCase											=     floats_tensor((1, 3, 32, 32)     ,       rng=random.Random(_SCREAMING_SNAKE_CASE		)		).to(_SCREAMING_SNAKE_CASE		)
									_UpperCAmelCase											=     floats_tensor((1, 3, 16, 16)     ,       rng=random.Random(_SCREAMING_SNAKE_CASE		)		).to(_SCREAMING_SNAKE_CASE		)

									_UpperCAmelCase											=     {
									    '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       UpperCAmelCase__							(     self		)					->			Dict:




									"""simple docstring"""





									self._test_xformers_attention_forwardGenerator_pass(expected_max_diff=1e-3		)
		def       UpperCAmelCase__							(     self		)					->			Dict:




									"""simple docstring"""





									self._test_save_load_optional_components()
		@unittest.skipIf(torch_device != 'cuda'     ,       reason='float16 requires CUDA'		)
		def       UpperCAmelCase__							(     self		)					->			List[Any]:




									"""simple docstring"""





									super().test_save_load_floataa(expected_max_diff=1e-1		)
		def       UpperCAmelCase__							(     self		)					->			Union[str, Any]:




									"""simple docstring"""





									self._test_attention_slicing_forward_pass(expected_max_diff=1e-2		)
		def       UpperCAmelCase__							(     self		)					->			Tuple:




									"""simple docstring"""





									self._test_save_load_local()






		def       UpperCAmelCase__							(     self		)					->			Tuple:




									"""simple docstring"""





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





def 	_lowerCAmelCase (    A__ = 600_851_475_143						):

      try:
            lowercase__  =	int(A__						)
      except (TypeError, ValueError):
            raise TypeError('Parameter n must be int or castable to int.'						)
      if n <= 0:
            raise ValueError('Parameter n must be greater than or equal to one.'						)
      lowercase__  =	2
      lowercase__  =	0
      if n == 2:
            return 2
      while n > 2:
            while n % i != 0:
                  i += 1
            lowercase__  =	i
            while n % i == 0:
                  lowercase__  =	n // i
            i += 1
      return int(A__						)


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