




"""simple docstring"""






import random
import unittest

import torch

from diffusers import IFInpaintingPipeline
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__			(       UpperCamelCase_					,	UpperCamelCase_					,	unittest.TestCase  ):
						snake_case__             = IFInpaintingPipeline
						snake_case__             = TEXT_GUIDED_IMAGE_INPAINTING_PARAMS - {'''width''', '''height'''}
						snake_case__             = TEXT_GUIDED_IMAGE_INPAINTING_BATCH_PARAMS
						snake_case__             = PipelineTesterMixin.required_optional_params - {'''latents'''}





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




											"""simple docstring"""







											return self._get_dummy_components()





						def       __UpperCamelCase     (							self      :	Any     ,a__      :	Dict     ,a__      :	Optional[Any]=0)						->       Optional[int]:




											"""simple docstring"""







											if str(a__).startswith('''mps'''):
																_lowerCAmelCase:Tuple									=  torch.manual_seed(a__)
											else:
																_lowerCAmelCase:List[Any]									=  torch.Generator(device=a__).manual_seed(a__)

											_lowerCAmelCase:Optional[int]									=  floats_tensor((1, 3, 32, 32)     ,rng=random.Random(a__)).to(a__)
											_lowerCAmelCase:Tuple									=  floats_tensor((1, 3, 32, 32)     ,rng=random.Random(a__)).to(a__)

											_lowerCAmelCase:Tuple									=  {
											    '''prompt''': '''A painting of a squirrel eating a burger''',
											    '''image''': 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      :	Dict)						->       List[str]:




											"""simple docstring"""







											self._test_xformers_attention_forwardGenerator_pass(expected_max_diff=1E-3)





						def       __UpperCamelCase     (							self      :	Dict)						->       Tuple:




											"""simple docstring"""







											self._test_save_load_optional_components()





						@unittest.skipIf(torch_device != '''cuda'''     ,reason='''float16 requires CUDA''')
						def       __UpperCamelCase     (							self      :	Tuple)						->       Optional[int]:




											"""simple docstring"""







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





						def       __UpperCamelCase     (							self      :	Dict)						->       Dict:




											"""simple docstring"""







											self._test_attention_slicing_forward_pass(expected_max_diff=1E-2)





						def       __UpperCamelCase     (							self      :	List[Any])						->       List[Any]:




											"""simple docstring"""







											self._test_save_load_local()







						def       __UpperCamelCase     (							self      :	Any)						->       List[Any]:




											"""simple docstring"""







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












"""simple docstring"""






# NOTE: This file is deprecated and will be removed in a future version.
# It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works

from ...utils import deprecate
from ..controlnet.pipeline_flax_controlnet import FlaxStableDiffusionControlNetPipeline  # noqa: F401


deprecate(
    '''stable diffusion controlnet''',
    '''0.22.0''',
    '''Importing `FlaxStableDiffusionControlNetPipeline` from diffusers.pipelines.stable_diffusion.flax_pipeline_stable_diffusion_controlnet is deprecated. Please import `from diffusers import FlaxStableDiffusionControlNetPipeline` instead.''',
    standard_warn=False,
    stacklevel=3,
)






