

'''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 							A__    (       __a     ,   __a     ,   unittest.TestCase  ):
  A__		 =				IFInpaintingSuperResolutionPipeline
  A__		 =				TEXT_GUIDED_IMAGE_INPAINTING_PARAMS - {'width', 'height'}
  A__		 =				TEXT_GUIDED_IMAGE_INPAINTING_BATCH_PARAMS.union({'original_image'}  )
  A__		 =				PipelineTesterMixin.required_optional_params - {'latents'}





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





       '''simple docstring'''






       return self._get_superresolution_dummy_components()





  def 						A  (		self      :	str							,					_a      :	str							,					_a      :	Tuple=0 )	->    Dict:





       '''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, 16, 16)							,					rng=random.Random(a_ ) ).to(a_ )
       _SCREAMING_SNAKE_CASE							    =floats_tensor((1, 3, 32, 32)							,					rng=random.Random(a_ ) ).to(a_ )
       _SCREAMING_SNAKE_CASE							    =floats_tensor((1, 3, 32, 32)							,					rng=random.Random(a_ ) ).to(a_ )

       _SCREAMING_SNAKE_CASE							    ={
           """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 						A  (		self      :	Dict )	->    Union[str, Any]:





       '''simple docstring'''






       self._test_xformers_attention_forwardGenerator_pass(expected_max_diff=1e-3 )





  def 						A  (		self      :	Tuple )	->    Dict:





       '''simple docstring'''






       self._test_save_load_optional_components()





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





       '''simple docstring'''






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





  def 						A  (		self      :	Optional[int] )	->    str:





       '''simple docstring'''






       self._test_attention_slicing_forward_pass(expected_max_diff=1e-2 )





  def 						A  (		self      :	Dict )	->    Optional[Any]:





       '''simple docstring'''






       self._test_save_load_local()





  def 						A  (		self      :	int )	->    Optional[Any]:





       '''simple docstring'''






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






"""simple docstring"""


from math import factorial

A_						=				{str(d): factorial(d) for d in range(10)}


def 					UpperCAmelCase__       (snake_case__							:					int    ):
  """simple docstring"""

  return sum(DIGIT_FACTORIAL[d] for d in str(snake_case__    )    )


def 					UpperCAmelCase__       ():
  """simple docstring"""

  _snake_case							:		List[str]								=  7 * factorial(9    ) + 1
  return sum(i for i in range(3		,   snake_case__    ) if sum_of_digit_factorial(snake_case__    ) == i    )


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


