





'''simple docstring'''




import gc
import random
import unittest

import torch

from diffusers import (
    IFImgaImgPipeline,
    IFImgaImgSuperResolutionPipeline,
    IFInpaintingPipeline,
    IFInpaintingSuperResolutionPipeline,
    IFPipeline,
    IFSuperResolutionPipeline,
)
from diffusers.models.attention_processor import AttnAddedKVProcessor
from diffusers.utils.import_utils import is_xformers_available
from diffusers.utils.testing_utils import floats_tensor, load_numpy, require_torch_gpu, skip_mps, slow, torch_device

from ..pipeline_params import TEXT_TO_IMAGE_BATCH_PARAMS, TEXT_TO_IMAGE_PARAMS
from ..test_pipelines_common import PipelineTesterMixin, assert_mean_pixel_difference
from . import IFPipelineTesterMixin




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




					"""simple docstring"""
					SCREAMING_SNAKE_CASE__				=	IFPipeline
					SCREAMING_SNAKE_CASE__				=	TEXT_TO_IMAGE_PARAMS - {'''width''', '''height''', '''latents'''}
					SCREAMING_SNAKE_CASE__				=	TEXT_TO_IMAGE_BATCH_PARAMS
					SCREAMING_SNAKE_CASE__				=	PipelineTesterMixin.required_optional_params - {'''latents'''}


					def lowerCamelCase_			(						self				:			Any						):

							'''simple docstring'''



							return self._get_dummy_components()


					def lowerCamelCase_			(						self				:			Optional[Any]      ,						lowerCamelCase_				:			List[str]      ,						lowerCamelCase_				:			List[str]=0						):

							'''simple docstring'''



							if str(lowerCamelCase_						).startswith("""mps"""						):
									SCREAMING_SNAKE_CASE :				Dict		=			torch.manual_seed(lowerCamelCase_						)
							else:
									SCREAMING_SNAKE_CASE :				Union[str, Any]		=			torch.Generator(device=lowerCamelCase_						).manual_seed(lowerCamelCase_						)

							SCREAMING_SNAKE_CASE :				Dict		=			{
							    """prompt""": """A painting of a squirrel eating a burger""",
							    """generator""": generator,
							    """num_inference_steps""": 2,
							    """output_type""": """numpy""",
							}

							return inputs


					def lowerCamelCase_			(						self				:			Dict						):

							'''simple docstring'''



							self._test_save_load_optional_components()


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

							'''simple docstring'''



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


					def lowerCamelCase_			(						self				:			List[str]						):

							'''simple docstring'''



							self._test_attention_slicing_forward_pass(expected_max_diff=1e-2						)


					def lowerCamelCase_			(						self				:			List[str]						):

							'''simple docstring'''



							self._test_save_load_local()


					def lowerCamelCase_			(						self				:			Optional[int]						):

							'''simple docstring'''



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



					@unittest.skipIf(
					    torch_device != """cuda""" or not is_xformers_available()      ,						reason="""XFormers attention is only available with CUDA and `xformers` installed"""      ,						)
					def lowerCamelCase_			(						self				:			Tuple						):

							'''simple docstring'''



							self._test_xformers_attention_forwardGenerator_pass(expected_max_diff=1e-3						)







@slow
@require_torch_gpu
class      UpperCamelCase__					(					unittest.TestCase			):




					"""simple docstring"""


					def lowerCamelCase_			(						self				:			int						):

							'''simple docstring'''



							super().tearDown()
							gc.collect()
							torch.cuda.empty_cache()


					def lowerCamelCase_			(						self				:			str						):

							'''simple docstring'''



							SCREAMING_SNAKE_CASE :				Tuple		=			IFPipeline.from_pretrained("""DeepFloyd/IF-I-XL-v1.0"""      ,						variant="""fp16"""      ,						torch_dtype=torch.floataa						)

							SCREAMING_SNAKE_CASE :				Tuple		=			IFSuperResolutionPipeline.from_pretrained(
							    """DeepFloyd/IF-II-L-v1.0"""      ,						variant="""fp16"""      ,						torch_dtype=torch.floataa      ,						text_encoder=lowerCamelCase_      ,						tokenizer=lowerCamelCase_						)

							# pre compute text embeddings and remove T5 to save memory

							pipe_a.text_encoder.to("""cuda"""						)

							SCREAMING_SNAKE_CASE,							SCREAMING_SNAKE_CASE :				Tuple		=			pipe_a.encode_prompt("""anime turtle"""      ,						device="""cuda"""						)

							del pipe_a.tokenizer
							del pipe_a.text_encoder
							gc.collect()

							SCREAMING_SNAKE_CASE :				Dict		=			None
							SCREAMING_SNAKE_CASE :				Tuple		=			None

							pipe_a.enable_model_cpu_offload()
							pipe_a.enable_model_cpu_offload()

							pipe_a.unet.set_attn_processor(AttnAddedKVProcessor()						)
							pipe_a.unet.set_attn_processor(AttnAddedKVProcessor()						)

							self._test_if(lowerCamelCase_      ,						lowerCamelCase_      ,						lowerCamelCase_      ,						lowerCamelCase_						)

							pipe_a.remove_all_hooks()
							pipe_a.remove_all_hooks()

							# img2img

							SCREAMING_SNAKE_CASE :				Union[str, Any]		=			IFImgaImgPipeline(**pipe_a.components						)
							SCREAMING_SNAKE_CASE :				Any		=			IFImgaImgSuperResolutionPipeline(**pipe_a.components						)

							pipe_a.enable_model_cpu_offload()
							pipe_a.enable_model_cpu_offload()

							pipe_a.unet.set_attn_processor(AttnAddedKVProcessor()						)
							pipe_a.unet.set_attn_processor(AttnAddedKVProcessor()						)

							self._test_if_imgaimg(lowerCamelCase_      ,						lowerCamelCase_      ,						lowerCamelCase_      ,						lowerCamelCase_						)

							pipe_a.remove_all_hooks()
							pipe_a.remove_all_hooks()

							# inpainting

							SCREAMING_SNAKE_CASE :				str		=			IFInpaintingPipeline(**pipe_a.components						)
							SCREAMING_SNAKE_CASE :				List[str]		=			IFInpaintingSuperResolutionPipeline(**pipe_a.components						)

							pipe_a.enable_model_cpu_offload()
							pipe_a.enable_model_cpu_offload()

							pipe_a.unet.set_attn_processor(AttnAddedKVProcessor()						)
							pipe_a.unet.set_attn_processor(AttnAddedKVProcessor()						)

							self._test_if_inpainting(lowerCamelCase_      ,						lowerCamelCase_      ,						lowerCamelCase_      ,						lowerCamelCase_						)


					def lowerCamelCase_			(						self				:			List[Any]      ,						lowerCamelCase_				:			Union[str, Any]      ,						lowerCamelCase_				:			List[str]      ,						lowerCamelCase_				:			Tuple      ,						lowerCamelCase_				:			List[str]						):

							'''simple docstring'''



							_start_torch_memory_measurement()

							SCREAMING_SNAKE_CASE :				Optional[int]		=			torch.Generator(device="""cpu"""						).manual_seed(0						)
							SCREAMING_SNAKE_CASE :				Dict		=			pipe_a(
							    prompt_embeds=lowerCamelCase_      ,						negative_prompt_embeds=lowerCamelCase_      ,						num_inference_steps=2      ,						generator=lowerCamelCase_      ,						output_type="""np"""      ,						)

							SCREAMING_SNAKE_CASE :				Optional[int]		=			output.images[0]

							assert image.shape == (64, 64, 3)

							SCREAMING_SNAKE_CASE :				List[Any]		=			torch.cuda.max_memory_allocated()
							assert mem_bytes < 13 * 10**9

							SCREAMING_SNAKE_CASE :				Union[str, Any]		=			load_numpy(
							    """https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/if/test_if.npy"""						)
							assert_mean_pixel_difference(lowerCamelCase_      ,						lowerCamelCase_						)

							# pipeline 2

							_start_torch_memory_measurement()

							SCREAMING_SNAKE_CASE :				Dict		=			torch.Generator(device="""cpu"""						).manual_seed(0						)

							SCREAMING_SNAKE_CASE :				str		=			floats_tensor((1, 3, 64, 64)      ,						rng=random.Random(0						)						).to(lowerCamelCase_						)

							SCREAMING_SNAKE_CASE :				str		=			pipe_a(
							    prompt_embeds=lowerCamelCase_      ,						negative_prompt_embeds=lowerCamelCase_      ,						image=lowerCamelCase_      ,						generator=lowerCamelCase_      ,						num_inference_steps=2      ,						output_type="""np"""      ,						)

							SCREAMING_SNAKE_CASE :				Any		=			output.images[0]

							assert image.shape == (2_56, 2_56, 3)

							SCREAMING_SNAKE_CASE :				int		=			torch.cuda.max_memory_allocated()
							assert mem_bytes < 4 * 10**9

							SCREAMING_SNAKE_CASE :				Any		=			load_numpy(
							    """https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/if/test_if_superresolution_stage_II.npy"""						)
							assert_mean_pixel_difference(lowerCamelCase_      ,						lowerCamelCase_						)


					def lowerCamelCase_			(						self				:			List[str]      ,						lowerCamelCase_				:			Union[str, Any]      ,						lowerCamelCase_				:			Tuple      ,						lowerCamelCase_				:			Dict      ,						lowerCamelCase_				:			Optional[Any]						):

							'''simple docstring'''



							_start_torch_memory_measurement()

							SCREAMING_SNAKE_CASE :				str		=			floats_tensor((1, 3, 64, 64)      ,						rng=random.Random(0						)						).to(lowerCamelCase_						)

							SCREAMING_SNAKE_CASE :				Dict		=			torch.Generator(device="""cpu"""						).manual_seed(0						)

							SCREAMING_SNAKE_CASE :				Tuple		=			pipe_a(
							    prompt_embeds=lowerCamelCase_      ,						negative_prompt_embeds=lowerCamelCase_      ,						image=lowerCamelCase_      ,						num_inference_steps=2      ,						generator=lowerCamelCase_      ,						output_type="""np"""      ,						)

							SCREAMING_SNAKE_CASE :				str		=			output.images[0]

							assert image.shape == (64, 64, 3)

							SCREAMING_SNAKE_CASE :				Any		=			torch.cuda.max_memory_allocated()
							assert mem_bytes < 10 * 10**9

							SCREAMING_SNAKE_CASE :				Union[str, Any]		=			load_numpy(
							    """https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/if/test_if_img2img.npy"""						)
							assert_mean_pixel_difference(lowerCamelCase_      ,						lowerCamelCase_						)

							# pipeline 2

							_start_torch_memory_measurement()

							SCREAMING_SNAKE_CASE :				Tuple		=			torch.Generator(device="""cpu"""						).manual_seed(0						)

							SCREAMING_SNAKE_CASE :				Optional[Any]		=			floats_tensor((1, 3, 2_56, 2_56)      ,						rng=random.Random(0						)						).to(lowerCamelCase_						)
							SCREAMING_SNAKE_CASE :				List[str]		=			floats_tensor((1, 3, 64, 64)      ,						rng=random.Random(0						)						).to(lowerCamelCase_						)

							SCREAMING_SNAKE_CASE :				List[Any]		=			pipe_a(
							    prompt_embeds=lowerCamelCase_      ,						negative_prompt_embeds=lowerCamelCase_      ,						image=lowerCamelCase_      ,						original_image=lowerCamelCase_      ,						generator=lowerCamelCase_      ,						num_inference_steps=2      ,						output_type="""np"""      ,						)

							SCREAMING_SNAKE_CASE :				Optional[int]		=			output.images[0]

							assert image.shape == (2_56, 2_56, 3)

							SCREAMING_SNAKE_CASE :				Dict		=			torch.cuda.max_memory_allocated()
							assert mem_bytes < 4 * 10**9

							SCREAMING_SNAKE_CASE :				List[str]		=			load_numpy(
							    """https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/if/test_if_img2img_superresolution_stage_II.npy"""						)
							assert_mean_pixel_difference(lowerCamelCase_      ,						lowerCamelCase_						)



					def lowerCamelCase_			(						self				:			List[Any]      ,						lowerCamelCase_				:			Tuple      ,						lowerCamelCase_				:			List[Any]      ,						lowerCamelCase_				:			List[str]      ,						lowerCamelCase_				:			Optional[int]						):

							'''simple docstring'''



							_start_torch_memory_measurement()

							SCREAMING_SNAKE_CASE :				List[str]		=			floats_tensor((1, 3, 64, 64)      ,						rng=random.Random(0						)						).to(lowerCamelCase_						)
							SCREAMING_SNAKE_CASE :				Tuple		=			floats_tensor((1, 3, 64, 64)      ,						rng=random.Random(1						)						).to(lowerCamelCase_						)

							SCREAMING_SNAKE_CASE :				Optional[Any]		=			torch.Generator(device="""cpu"""						).manual_seed(0						)
							SCREAMING_SNAKE_CASE :				Union[str, Any]		=			pipe_a(
							    prompt_embeds=lowerCamelCase_      ,						negative_prompt_embeds=lowerCamelCase_      ,						image=lowerCamelCase_      ,						mask_image=lowerCamelCase_      ,						num_inference_steps=2      ,						generator=lowerCamelCase_      ,						output_type="""np"""      ,						)

							SCREAMING_SNAKE_CASE :				str		=			output.images[0]

							assert image.shape == (64, 64, 3)

							SCREAMING_SNAKE_CASE :				List[Any]		=			torch.cuda.max_memory_allocated()
							assert mem_bytes < 10 * 10**9

							SCREAMING_SNAKE_CASE :				int		=			load_numpy(
							    """https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/if/test_if_inpainting.npy"""						)
							assert_mean_pixel_difference(lowerCamelCase_      ,						lowerCamelCase_						)

							# pipeline 2

							_start_torch_memory_measurement()

							SCREAMING_SNAKE_CASE :				List[Any]		=			torch.Generator(device="""cpu"""						).manual_seed(0						)

							SCREAMING_SNAKE_CASE :				Dict		=			floats_tensor((1, 3, 64, 64)      ,						rng=random.Random(0						)						).to(lowerCamelCase_						)
							SCREAMING_SNAKE_CASE :				Optional[Any]		=			floats_tensor((1, 3, 2_56, 2_56)      ,						rng=random.Random(0						)						).to(lowerCamelCase_						)
							SCREAMING_SNAKE_CASE :				Dict		=			floats_tensor((1, 3, 2_56, 2_56)      ,						rng=random.Random(1						)						).to(lowerCamelCase_						)

							SCREAMING_SNAKE_CASE :				int		=			pipe_a(
							    prompt_embeds=lowerCamelCase_      ,						negative_prompt_embeds=lowerCamelCase_      ,						image=lowerCamelCase_      ,						mask_image=lowerCamelCase_      ,						original_image=lowerCamelCase_      ,						generator=lowerCamelCase_      ,						num_inference_steps=2      ,						output_type="""np"""      ,						)

							SCREAMING_SNAKE_CASE :				Any		=			output.images[0]

							assert image.shape == (2_56, 2_56, 3)

							SCREAMING_SNAKE_CASE :				List[Any]		=			torch.cuda.max_memory_allocated()
							assert mem_bytes < 4 * 10**9

							SCREAMING_SNAKE_CASE :				int		=			load_numpy(
							    """https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/if/test_if_inpainting_superresolution_stage_II.npy"""						)
							assert_mean_pixel_difference(lowerCamelCase_      ,						lowerCamelCase_						)







def 		__A		(  ):


		"""simple docstring"""



		torch.cuda.empty_cache()
		torch.cuda.reset_max_memory_allocated()
		torch.cuda.reset_peak_memory_stats()










'''simple docstring'''




from typing import Any, Callable, Dict, List, Optional, Union

import torch
from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer

from diffusers import (
    AutoencoderKL,
    DDIMScheduler,
    DiffusionPipeline,
    LMSDiscreteScheduler,
    PNDMScheduler,
    StableDiffusionPipeline,
    UNetaDConditionModel,
)
from diffusers.pipelines.stable_diffusion import StableDiffusionPipelineOutput
from diffusers.pipelines.stable_diffusion.safety_checker import StableDiffusionSafetyChecker


__UpperCAmelCase            =       """CompVis/stable-diffusion-v1-1"""
__UpperCAmelCase            =       """CompVis/stable-diffusion-v1-2"""
__UpperCAmelCase            =       """CompVis/stable-diffusion-v1-3"""
__UpperCAmelCase            =       """CompVis/stable-diffusion-v1-4"""




class      UpperCamelCase__					(					lowercase_			):




					"""simple docstring"""


					def __init__(						self				:			List[str]      ,						lowerCamelCase_				:			AutoencoderKL      ,						lowerCamelCase_				:			CLIPTextModel      ,						lowerCamelCase_				:			CLIPTokenizer      ,						lowerCamelCase_				:			UNetaDConditionModel      ,						lowerCamelCase_				:			Union[DDIMScheduler, PNDMScheduler, LMSDiscreteScheduler]      ,						lowerCamelCase_				:			StableDiffusionSafetyChecker      ,						lowerCamelCase_				:			CLIPImageProcessor      ,						lowerCamelCase_				:			bool = True      ,						):

							'''simple docstring'''



							super()._init_()

							SCREAMING_SNAKE_CASE :				Tuple		=			StableDiffusionPipeline.from_pretrained(lowerCamelCase_						)
							SCREAMING_SNAKE_CASE :				List[Any]		=			StableDiffusionPipeline.from_pretrained(lowerCamelCase_						)
							SCREAMING_SNAKE_CASE :				List[Any]		=			StableDiffusionPipeline.from_pretrained(lowerCamelCase_						)
							SCREAMING_SNAKE_CASE :				Optional[int]		=			StableDiffusionPipeline(
							    vae=lowerCamelCase_      ,						text_encoder=lowerCamelCase_      ,						tokenizer=lowerCamelCase_      ,						unet=lowerCamelCase_      ,						scheduler=lowerCamelCase_      ,						safety_checker=lowerCamelCase_      ,						feature_extractor=lowerCamelCase_      ,						requires_safety_checker=lowerCamelCase_      ,						)

							self.register_modules(pipelinea=self.pipea      ,						pipelinea=self.pipea      ,						pipelinea=self.pipea      ,						pipelinea=self.pipea						)


					@property
					def lowerCamelCase_			(						self				:			int						):

							'''simple docstring'''



							return {k: getattr(self      ,						lowerCamelCase_						) for k in self.config.keys() if not k.startswith("""_"""						)}


					def lowerCamelCase_			(						self				:			Any      ,						lowerCamelCase_				:			Optional[Union[str, int]] = "auto"						):

							'''simple docstring'''



							if slice_size == "auto":
									# half the attention head size is usually a good trade-off between
									# speed and memory
									SCREAMING_SNAKE_CASE :				Optional[int]		=			self.unet.config.attention_head_dim // 2
							self.unet.set_attention_slice(lowerCamelCase_						)


					def lowerCamelCase_			(						self				:			Dict						):

							'''simple docstring'''



							self.enable_attention_slicing(lowerCamelCase_						)


					@torch.no_grad()
					def lowerCamelCase_			(						self				:			Optional[Any]      ,						lowerCamelCase_				:			Union[str, List[str]]      ,						lowerCamelCase_				:			int = 5_12      ,						lowerCamelCase_				:			int = 5_12      ,						lowerCamelCase_				:			int = 50      ,						lowerCamelCase_				:			float = 7.5      ,						lowerCamelCase_				:			Optional[Union[str, List[str]]] = None      ,						lowerCamelCase_				:			Optional[int] = 1      ,						lowerCamelCase_				:			float = 0.0      ,						lowerCamelCase_				:			Optional[torch.Generator] = None      ,						lowerCamelCase_				:			Optional[torch.FloatTensor] = None      ,						lowerCamelCase_				:			Optional[str] = "pil"      ,						lowerCamelCase_				:			bool = True      ,						lowerCamelCase_				:			Optional[Callable[[int, int, torch.FloatTensor], None]] = None      ,						lowerCamelCase_				:			int = 1      ,						**lowerCamelCase_				:			Union[str, Any]      ,						):

							'''simple docstring'''



							return self.pipea(
							    prompt=lowerCamelCase_      ,						height=lowerCamelCase_      ,						width=lowerCamelCase_      ,						num_inference_steps=lowerCamelCase_      ,						guidance_scale=lowerCamelCase_      ,						negative_prompt=lowerCamelCase_      ,						num_images_per_prompt=lowerCamelCase_      ,						eta=lowerCamelCase_      ,						generator=lowerCamelCase_      ,						latents=lowerCamelCase_      ,						output_type=lowerCamelCase_      ,						return_dict=lowerCamelCase_      ,						callback=lowerCamelCase_      ,						callback_steps=lowerCamelCase_      ,						**lowerCamelCase_      ,						)


					@torch.no_grad()
					def lowerCamelCase_			(						self				:			Optional[int]      ,						lowerCamelCase_				:			Union[str, List[str]]      ,						lowerCamelCase_				:			int = 5_12      ,						lowerCamelCase_				:			int = 5_12      ,						lowerCamelCase_				:			int = 50      ,						lowerCamelCase_				:			float = 7.5      ,						lowerCamelCase_				:			Optional[Union[str, List[str]]] = None      ,						lowerCamelCase_				:			Optional[int] = 1      ,						lowerCamelCase_				:			float = 0.0      ,						lowerCamelCase_				:			Optional[torch.Generator] = None      ,						lowerCamelCase_				:			Optional[torch.FloatTensor] = None      ,						lowerCamelCase_				:			Optional[str] = "pil"      ,						lowerCamelCase_				:			bool = True      ,						lowerCamelCase_				:			Optional[Callable[[int, int, torch.FloatTensor], None]] = None      ,						lowerCamelCase_				:			int = 1      ,						**lowerCamelCase_				:			Union[str, Any]      ,						):

							'''simple docstring'''



							return self.pipea(
							    prompt=lowerCamelCase_      ,						height=lowerCamelCase_      ,						width=lowerCamelCase_      ,						num_inference_steps=lowerCamelCase_      ,						guidance_scale=lowerCamelCase_      ,						negative_prompt=lowerCamelCase_      ,						num_images_per_prompt=lowerCamelCase_      ,						eta=lowerCamelCase_      ,						generator=lowerCamelCase_      ,						latents=lowerCamelCase_      ,						output_type=lowerCamelCase_      ,						return_dict=lowerCamelCase_      ,						callback=lowerCamelCase_      ,						callback_steps=lowerCamelCase_      ,						**lowerCamelCase_      ,						)


					@torch.no_grad()
					def lowerCamelCase_			(						self				:			Optional[Any]      ,						lowerCamelCase_				:			Union[str, List[str]]      ,						lowerCamelCase_				:			int = 5_12      ,						lowerCamelCase_				:			int = 5_12      ,						lowerCamelCase_				:			int = 50      ,						lowerCamelCase_				:			float = 7.5      ,						lowerCamelCase_				:			Optional[Union[str, List[str]]] = None      ,						lowerCamelCase_				:			Optional[int] = 1      ,						lowerCamelCase_				:			float = 0.0      ,						lowerCamelCase_				:			Optional[torch.Generator] = None      ,						lowerCamelCase_				:			Optional[torch.FloatTensor] = None      ,						lowerCamelCase_				:			Optional[str] = "pil"      ,						lowerCamelCase_				:			bool = True      ,						lowerCamelCase_				:			Optional[Callable[[int, int, torch.FloatTensor], None]] = None      ,						lowerCamelCase_				:			int = 1      ,						**lowerCamelCase_				:			str      ,						):

							'''simple docstring'''



							return self.pipea(
							    prompt=lowerCamelCase_      ,						height=lowerCamelCase_      ,						width=lowerCamelCase_      ,						num_inference_steps=lowerCamelCase_      ,						guidance_scale=lowerCamelCase_      ,						negative_prompt=lowerCamelCase_      ,						num_images_per_prompt=lowerCamelCase_      ,						eta=lowerCamelCase_      ,						generator=lowerCamelCase_      ,						latents=lowerCamelCase_      ,						output_type=lowerCamelCase_      ,						return_dict=lowerCamelCase_      ,						callback=lowerCamelCase_      ,						callback_steps=lowerCamelCase_      ,						**lowerCamelCase_      ,						)


					@torch.no_grad()
					def lowerCamelCase_			(						self				:			Tuple      ,						lowerCamelCase_				:			Union[str, List[str]]      ,						lowerCamelCase_				:			int = 5_12      ,						lowerCamelCase_				:			int = 5_12      ,						lowerCamelCase_				:			int = 50      ,						lowerCamelCase_				:			float = 7.5      ,						lowerCamelCase_				:			Optional[Union[str, List[str]]] = None      ,						lowerCamelCase_				:			Optional[int] = 1      ,						lowerCamelCase_				:			float = 0.0      ,						lowerCamelCase_				:			Optional[torch.Generator] = None      ,						lowerCamelCase_				:			Optional[torch.FloatTensor] = None      ,						lowerCamelCase_				:			Optional[str] = "pil"      ,						lowerCamelCase_				:			bool = True      ,						lowerCamelCase_				:			Optional[Callable[[int, int, torch.FloatTensor], None]] = None      ,						lowerCamelCase_				:			int = 1      ,						**lowerCamelCase_				:			Dict      ,						):

							'''simple docstring'''



							return self.pipea(
							    prompt=lowerCamelCase_      ,						height=lowerCamelCase_      ,						width=lowerCamelCase_      ,						num_inference_steps=lowerCamelCase_      ,						guidance_scale=lowerCamelCase_      ,						negative_prompt=lowerCamelCase_      ,						num_images_per_prompt=lowerCamelCase_      ,						eta=lowerCamelCase_      ,						generator=lowerCamelCase_      ,						latents=lowerCamelCase_      ,						output_type=lowerCamelCase_      ,						return_dict=lowerCamelCase_      ,						callback=lowerCamelCase_      ,						callback_steps=lowerCamelCase_      ,						**lowerCamelCase_      ,						)



					@torch.no_grad()
					def lowerCamelCase_			(						self				:			Dict      ,						lowerCamelCase_				:			Union[str, List[str]]      ,						lowerCamelCase_				:			int = 5_12      ,						lowerCamelCase_				:			int = 5_12      ,						lowerCamelCase_				:			int = 50      ,						lowerCamelCase_				:			float = 7.5      ,						lowerCamelCase_				:			Optional[Union[str, List[str]]] = None      ,						lowerCamelCase_				:			Optional[int] = 1      ,						lowerCamelCase_				:			float = 0.0      ,						lowerCamelCase_				:			Optional[torch.Generator] = None      ,						lowerCamelCase_				:			Optional[torch.FloatTensor] = None      ,						lowerCamelCase_				:			Optional[str] = "pil"      ,						lowerCamelCase_				:			bool = True      ,						lowerCamelCase_				:			Optional[Callable[[int, int, torch.FloatTensor], None]] = None      ,						lowerCamelCase_				:			int = 1      ,						**lowerCamelCase_				:			Any      ,						):

							'''simple docstring'''



							SCREAMING_SNAKE_CASE :				int		=			"""cuda""" if torch.cuda.is_available() else """cpu"""
							self.to(lowerCamelCase_						)

							# Checks if the height and width are divisible by 8 or not
							if height % 8 != 0 or width % 8 != 0:
									raise ValueError(f'''`height` and `width` must be divisible by 8 but are {height} and {width}.'''						)

							# Get first result from Stable Diffusion Checkpoint v1.1
							SCREAMING_SNAKE_CASE :				List[str]		=			self.textaimg_sda_a(
							    prompt=lowerCamelCase_      ,						height=lowerCamelCase_      ,						width=lowerCamelCase_      ,						num_inference_steps=lowerCamelCase_      ,						guidance_scale=lowerCamelCase_      ,						negative_prompt=lowerCamelCase_      ,						num_images_per_prompt=lowerCamelCase_      ,						eta=lowerCamelCase_      ,						generator=lowerCamelCase_      ,						latents=lowerCamelCase_      ,						output_type=lowerCamelCase_      ,						return_dict=lowerCamelCase_      ,						callback=lowerCamelCase_      ,						callback_steps=lowerCamelCase_      ,						**lowerCamelCase_      ,						)

							# Get first result from Stable Diffusion Checkpoint v1.2
							SCREAMING_SNAKE_CASE :				Union[str, Any]		=			self.textaimg_sda_a(
							    prompt=lowerCamelCase_      ,						height=lowerCamelCase_      ,						width=lowerCamelCase_      ,						num_inference_steps=lowerCamelCase_      ,						guidance_scale=lowerCamelCase_      ,						negative_prompt=lowerCamelCase_      ,						num_images_per_prompt=lowerCamelCase_      ,						eta=lowerCamelCase_      ,						generator=lowerCamelCase_      ,						latents=lowerCamelCase_      ,						output_type=lowerCamelCase_      ,						return_dict=lowerCamelCase_      ,						callback=lowerCamelCase_      ,						callback_steps=lowerCamelCase_      ,						**lowerCamelCase_      ,						)

							# Get first result from Stable Diffusion Checkpoint v1.3
							SCREAMING_SNAKE_CASE :				int		=			self.textaimg_sda_a(
							    prompt=lowerCamelCase_      ,						height=lowerCamelCase_      ,						width=lowerCamelCase_      ,						num_inference_steps=lowerCamelCase_      ,						guidance_scale=lowerCamelCase_      ,						negative_prompt=lowerCamelCase_      ,						num_images_per_prompt=lowerCamelCase_      ,						eta=lowerCamelCase_      ,						generator=lowerCamelCase_      ,						latents=lowerCamelCase_      ,						output_type=lowerCamelCase_      ,						return_dict=lowerCamelCase_      ,						callback=lowerCamelCase_      ,						callback_steps=lowerCamelCase_      ,						**lowerCamelCase_      ,						)

							# Get first result from Stable Diffusion Checkpoint v1.4
							SCREAMING_SNAKE_CASE :				Optional[int]		=			self.textaimg_sda_a(
							    prompt=lowerCamelCase_      ,						height=lowerCamelCase_      ,						width=lowerCamelCase_      ,						num_inference_steps=lowerCamelCase_      ,						guidance_scale=lowerCamelCase_      ,						negative_prompt=lowerCamelCase_      ,						num_images_per_prompt=lowerCamelCase_      ,						eta=lowerCamelCase_      ,						generator=lowerCamelCase_      ,						latents=lowerCamelCase_      ,						output_type=lowerCamelCase_      ,						return_dict=lowerCamelCase_      ,						callback=lowerCamelCase_      ,						callback_steps=lowerCamelCase_      ,						**lowerCamelCase_      ,						)

							# Get all result images into a single list and pass it via StableDiffusionPipelineOutput for final result
							return StableDiffusionPipelineOutput([resa[0], resa[0], resa[0], resa[0]]						)



