




import gc
import unittest

import numpy as np
import torch
from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer

from diffusers import (
    AutoencoderKL,
    DDIMScheduler,
    PNDMScheduler,
    StableDiffusionLDMaDPipeline,
    UNetaDConditionModel,
)
from diffusers.utils import nightly, slow, torch_device
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu

from ..pipeline_params import TEXT_TO_IMAGE_BATCH_PARAMS, TEXT_TO_IMAGE_IMAGE_PARAMS, TEXT_TO_IMAGE_PARAMS


enable_full_determinism()


class 							UpperCamelCase_       (					unittest.TestCase	):

    '''simple docstring'''






    UpperCAmelCase__				    = StableDiffusionLDMaDPipeline
    UpperCAmelCase__				    = TEXT_TO_IMAGE_PARAMS
    UpperCAmelCase__				    = TEXT_TO_IMAGE_BATCH_PARAMS
    UpperCAmelCase__				    = TEXT_TO_IMAGE_IMAGE_PARAMS


    def 			SCREAMING_SNAKE_CASE				(     self :      Dict)		->Any:





           '''simple docstring'''

           torch.manual_seed(0)
           A__ 					=       UNetaDConditionModel(
               block_out_channels=(32, 64)   ,					layers_per_block=2   ,					sample_size=32   ,					in_channels=4   ,					out_channels=4   ,					down_block_types=('''DownBlock2D''', '''CrossAttnDownBlock2D''')   ,					up_block_types=('''CrossAttnUpBlock2D''', '''UpBlock2D''')   ,					cross_attention_dim=32   ,					)
           A__ 					=       DDIMScheduler(
               beta_start=0.00085   ,					beta_end=0.012   ,					beta_schedule='''scaled_linear'''   ,					clip_sample=lowerCamelCase_   ,					set_alpha_to_one=lowerCamelCase_   ,					)
           torch.manual_seed(0)
           A__ 					=       AutoencoderKL(
               block_out_channels=[32, 64]   ,					in_channels=6   ,					out_channels=6   ,					down_block_types=['''DownEncoderBlock2D''', '''DownEncoderBlock2D''']   ,					up_block_types=['''UpDecoderBlock2D''', '''UpDecoderBlock2D''']   ,					latent_channels=4   ,					)
           torch.manual_seed(0)
           A__ 					=       CLIPTextConfig(
               bos_token_id=0   ,					eos_token_id=2   ,					hidden_size=32   ,					intermediate_size=37   ,					layer_norm_eps=1e-05   ,					num_attention_heads=4   ,					num_hidden_layers=5   ,					pad_token_id=1   ,					vocab_size=1_000   ,					)
           A__ 					=       CLIPTextModel(lowerCamelCase_)
           A__ 					=       CLIPTokenizer.from_pretrained('''hf-internal-testing/tiny-random-clip''')

           A__ 					=       {
               """unet""": unet,
               """scheduler""": scheduler,
               """vae""": vae,
               """text_encoder""": text_encoder,
               """tokenizer""": tokenizer,
               """safety_checker""": None,
               """feature_extractor""": None,
           }
           return components


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





           '''simple docstring'''

           if str(lowerCamelCase_).startswith('''mps'''):
                  A__ 					=       torch.manual_seed(lowerCamelCase_)
           else:
                  A__ 					=       torch.Generator(device=lowerCamelCase_).manual_seed(lowerCamelCase_)
           A__ 					=       {
               """prompt""": """A painting of a squirrel eating a burger""",
               """generator""": generator,
               """num_inference_steps""": 2,
               """guidance_scale""": 6.0,
               """output_type""": """numpy""",
           }
           return inputs


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





           '''simple docstring'''

           A__ 					=       """cpu"""  # ensure determinism for the device-dependent torch.Generator

           A__ 					=       self.get_dummy_components()
           A__ 					=       StableDiffusionLDMaDPipeline(**lowerCamelCase_)
           A__ 					=       ldmad_pipe.to(lowerCamelCase_)
           ldmad_pipe.set_progress_bar_config(disable=lowerCamelCase_)

           A__ 					=       self.get_dummy_inputs(lowerCamelCase_)
           A__ 					=       ldmad_pipe(**lowerCamelCase_)
           A__ 					=       output.rgb, output.depth

           A__ 					=       rgb[0, -3:, -3:, -1]
           A__ 					=       depth[0, -3:, -1]

           assert rgb.shape == (1, 64, 64, 3)
           assert depth.shape == (1, 64, 64)

           A__ 					=       np.array(
               [0.37338176, 0.70247, 0.74203193, 0.51643604, 0.58256793, 0.60932136, 0.4181095, 0.48355877, 0.46535262])
           A__ 					=       np.array([103.46727, 85.812004, 87.849236])

           assert np.abs(image_slice_rgb.flatten() - expected_slice_rgb).max() < 1e-2
           assert np.abs(image_slice_depth.flatten() - expected_slice_depth).max() < 1e-2


    def 			SCREAMING_SNAKE_CASE				(     self :      Dict)		->List[str]:





           '''simple docstring'''

           A__ 					=       self.get_dummy_components()
           A__ 					=       StableDiffusionLDMaDPipeline(**lowerCamelCase_)
           A__ 					=       ldmad_pipe.to(lowerCamelCase_)
           ldmad_pipe.set_progress_bar_config(disable=lowerCamelCase_)

           A__ 					=       self.get_dummy_inputs(lowerCamelCase_)
           A__ 					=       3 * [inputs["""prompt"""]]

           # forward
           A__ 					=       ldmad_pipe(**lowerCamelCase_)
           A__ 					=       output.rgb, output.depth
           A__ 					=       rgb_slice_a[0, -3:, -3:, -1]
           A__ 					=       depth_slice_a[0, -3:, -1]

           A__ 					=       self.get_dummy_inputs(lowerCamelCase_)
           A__ 					=       3 * [inputs.pop('''prompt''')]

           A__ 					=       ldmad_pipe.tokenizer(
               lowerCamelCase_   ,					padding='''max_length'''   ,					max_length=ldmad_pipe.tokenizer.model_max_length   ,					truncation=lowerCamelCase_   ,					return_tensors='''pt'''   ,					)
           A__ 					=       text_inputs["""input_ids"""].to(lowerCamelCase_)

           A__ 					=       ldmad_pipe.text_encoder(lowerCamelCase_)[0]

           A__ 					=       prompt_embeds

           # forward
           A__ 					=       ldmad_pipe(**lowerCamelCase_)
           A__ 					=       output.rgb, output.depth
           A__ 					=       rgb_slice_a[0, -3:, -3:, -1]
           A__ 					=       depth_slice_a[0, -3:, -1]

           assert np.abs(rgb_slice_a.flatten() - rgb_slice_a.flatten()).max() < 1e-4
           assert np.abs(depth_slice_a.flatten() - depth_slice_a.flatten()).max() < 1e-4





    def 			SCREAMING_SNAKE_CASE				(     self :      str)		->int:





           '''simple docstring'''

           A__ 					=       """cpu"""  # ensure determinism for the device-dependent torch.Generator
           A__ 					=       self.get_dummy_components()
           A__ 					=       PNDMScheduler(skip_prk_steps=lowerCamelCase_)
           A__ 					=       StableDiffusionLDMaDPipeline(**lowerCamelCase_)
           A__ 					=       ldmad_pipe.to(lowerCamelCase_)
           ldmad_pipe.set_progress_bar_config(disable=lowerCamelCase_)

           A__ 					=       self.get_dummy_inputs(lowerCamelCase_)
           A__ 					=       """french fries"""
           A__ 					=       ldmad_pipe(**lowerCamelCase_   ,					negative_prompt=lowerCamelCase_)

           A__ 					=       output.rgb, output.depth
           A__ 					=       rgb[0, -3:, -3:, -1]
           A__ 					=       depth[0, -3:, -1]

           assert rgb.shape == (1, 64, 64, 3)
           assert depth.shape == (1, 64, 64)

           A__ 					=       np.array(
               [0.37044, 0.71811503, 0.7223251, 0.48603675, 0.5638391, 0.6364948, 0.42833704, 0.4901315, 0.47926217])
           A__ 					=       np.array([107.84738, 84.62802, 89.962135])
           assert np.abs(rgb_slice.flatten() - expected_slice_rgb).max() < 1e-2
           assert np.abs(depth_slice.flatten() - expected_slice_depth).max() < 1e-2


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

    '''simple docstring'''






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





           '''simple docstring'''

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


    def 			SCREAMING_SNAKE_CASE				(     self :      Optional[Any]   ,					UpperCAmelCase__ :      Tuple   ,					UpperCAmelCase__ :      Dict="cpu"   ,					UpperCAmelCase__ :      int=torch.floataa   ,					UpperCAmelCase__ :      int=0)		->Optional[int]:





           '''simple docstring'''

           A__ 					=       torch.Generator(device=lowerCamelCase_).manual_seed(lowerCamelCase_)
           A__ 					=       np.random.RandomState(lowerCamelCase_).standard_normal((1, 4, 64, 64))
           A__ 					=       torch.from_numpy(lowerCamelCase_).to(device=lowerCamelCase_   ,					dtype=lowerCamelCase_)
           A__ 					=       {
               """prompt""": """a photograph of an astronaut riding a horse""",
               """latents""": latents,
               """generator""": generator,
               """num_inference_steps""": 3,
               """guidance_scale""": 7.5,
               """output_type""": """numpy""",
           }
           return inputs





    def 			SCREAMING_SNAKE_CASE				(     self :      Optional[int])		->Tuple:





           '''simple docstring'''

           A__ 					=       StableDiffusionLDMaDPipeline.from_pretrained('''Intel/ldm3d''')
           A__ 					=       ldmad_pipe.to(lowerCamelCase_)
           ldmad_pipe.set_progress_bar_config(disable=lowerCamelCase_)

           A__ 					=       self.get_inputs(lowerCamelCase_)
           A__ 					=       ldmad_pipe(**lowerCamelCase_)
           A__ 					=       output.rgb, output.depth
           A__ 					=       rgb[0, -3:, -3:, -1].flatten()
           A__ 					=       rgb[0, -3:, -1].flatten()

           assert rgb.shape == (1, 512, 512, 3)
           assert depth.shape == (1, 512, 512)

           A__ 					=       np.array(
               [0.53805465, 0.56707305, 0.5486515, 0.57012236, 0.5814511, 0.56253487, 0.54843014, 0.55092263, 0.6459706])
           A__ 					=       np.array(
               [0.9263781, 0.6678672, 0.5486515, 0.92202145, 0.67831135, 0.56253487, 0.9241694, 0.7551478, 0.6459706])
           assert np.abs(rgb_slice - expected_slice_rgb).max() < 3e-3
           assert np.abs(depth_slice - expected_slice_depth).max() < 3e-3


@nightly
@require_torch_gpu
class 							UpperCamelCase_       (					unittest.TestCase	):

    '''simple docstring'''






    def 			SCREAMING_SNAKE_CASE				(     self :      str)		->Optional[Any]:





           '''simple docstring'''

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


    def 			SCREAMING_SNAKE_CASE				(     self :      str   ,					UpperCAmelCase__ :      int   ,					UpperCAmelCase__ :      Tuple="cpu"   ,					UpperCAmelCase__ :      List[Any]=torch.floataa   ,					UpperCAmelCase__ :      Any=0)		->int:





           '''simple docstring'''

           A__ 					=       torch.Generator(device=lowerCamelCase_).manual_seed(lowerCamelCase_)
           A__ 					=       np.random.RandomState(lowerCamelCase_).standard_normal((1, 4, 64, 64))
           A__ 					=       torch.from_numpy(lowerCamelCase_).to(device=lowerCamelCase_   ,					dtype=lowerCamelCase_)
           A__ 					=       {
               """prompt""": """a photograph of an astronaut riding a horse""",
               """latents""": latents,
               """generator""": generator,
               """num_inference_steps""": 50,
               """guidance_scale""": 7.5,
               """output_type""": """numpy""",
           }
           return inputs


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





           '''simple docstring'''

           A__ 					=       StableDiffusionLDMaDPipeline.from_pretrained('''Intel/ldm3d''').to(lowerCamelCase_)
           ldmad_pipe.set_progress_bar_config(disable=lowerCamelCase_)

           A__ 					=       self.get_inputs(lowerCamelCase_)
           A__ 					=       ldmad_pipe(**lowerCamelCase_)
           A__ 					=       output.rgb, output.depth

           A__ 					=       0.495586
           A__ 					=       0.33795515
           A__ 					=       112.48518
           A__ 					=       98.489746
           assert np.abs(expected_rgb_mean - rgb.mean()) < 1e-3
           assert np.abs(expected_rgb_std - rgb.std()) < 1e-3
           assert np.abs(expected_depth_mean - depth.mean()) < 1e-3
           assert np.abs(expected_depth_std - depth.std()) < 1e-3





    def 			SCREAMING_SNAKE_CASE				(     self :      Any)		->str:





           '''simple docstring'''

           A__ 					=       StableDiffusionLDMaDPipeline.from_pretrained('''Intel/ldm3d-4c''').to(lowerCamelCase_)
           ldmad_pipe.set_progress_bar_config(disable=lowerCamelCase_)

           A__ 					=       self.get_inputs(lowerCamelCase_)
           A__ 					=       ldmad_pipe(**lowerCamelCase_)
           A__ 					=       output.rgb, output.depth

           A__ 					=       0.4194127
           A__ 					=       0.35375586
           A__ 					=       0.5638502
           A__ 					=       0.34686103

           assert rgb.shape == (1, 512, 512, 3)
           assert depth.shape == (1, 512, 512, 1)
           assert np.abs(expected_rgb_mean - rgb.mean()) < 1e-3
           assert np.abs(expected_rgb_std - rgb.std()) < 1e-3
           assert np.abs(expected_depth_mean - depth.mean()) < 1e-3
           assert np.abs(expected_depth_std - depth.std()) < 1e-3









'''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]]						)



