from dataclasses import dataclass
from typing import Dict, Optional, Union

import torch
import torch.nn.functional as F
from torch import nn

from ..configuration_utils import ConfigMixin, register_to_config
from ..utils import BaseOutput
from .attention import BasicTransformerBlock
from .attention_processor import AttentionProcessor, AttnProcessor
from .embeddings import TimestepEmbedding, Timesteps
from .modeling_utils import ModelMixin





@dataclass
class 					A							(    A__					):
   __UpperCAmelCase			:			torch.FloatTensor





class 					A							(    A__		,    A__					):


   @register_to_config
   def __init__(self					:						Any	,  __UpperCAmelCase					:						Any = 3_2	,  __UpperCAmelCase					:						Dict = 6_4	,  __UpperCAmelCase					:						Dict = 2_0	,  __UpperCAmelCase					:						List[Any] = 7_6_8	,  __UpperCAmelCase					:						Optional[Any]=7_7	,  __UpperCAmelCase					:						Dict=4	,  __UpperCAmelCase					:						Union[str, Any] = 0.0	,  __UpperCAmelCase					:						int = "silu"	,  __UpperCAmelCase					:						Any = None	,  __UpperCAmelCase					:						Tuple = None	,  __UpperCAmelCase					:						Union[str, Any] = "linear"	,  __UpperCAmelCase					:						List[Any] = "prd"	,  __UpperCAmelCase					:						Union[str, Any] = None	,  __UpperCAmelCase					:						str = None	,  __UpperCAmelCase					:						int = None	,  )						->    Dict:
         """simple docstring"""



         super().__init__()
         UpperCAmelCase__								=  num_attention_heads
         UpperCAmelCase__								=  attention_head_dim
         UpperCAmelCase__								=  num_attention_heads * attention_head_dim
         UpperCAmelCase__								=  additional_embeddings

         UpperCAmelCase__								=  time_embed_dim or inner_dim
         UpperCAmelCase__								=  embedding_proj_dim or embedding_dim
         UpperCAmelCase__								=  clip_embed_dim or embedding_dim

         UpperCAmelCase__								=  Timesteps(lowerCamelCase__	,  lowerCamelCase__	,  0		)
         UpperCAmelCase__								=  TimestepEmbedding(lowerCamelCase__	,  lowerCamelCase__	,  out_dim=lowerCamelCase__	,  act_fn=lowerCamelCase__		)

         UpperCAmelCase__								=  nn.Linear(lowerCamelCase__	,  lowerCamelCase__		)

         if embedding_proj_norm_type is None:
               UpperCAmelCase__								=  None
         elif embedding_proj_norm_type == "layer":
               UpperCAmelCase__								=  nn.LayerNorm(lowerCamelCase__		)
         else:
               raise ValueError(f"""unsupported embedding_proj_norm_type: {embedding_proj_norm_type}"""		)

         UpperCAmelCase__								=  nn.Linear(lowerCamelCase__	,  lowerCamelCase__		)

         if encoder_hid_proj_type is None:
               UpperCAmelCase__								=  None
         elif encoder_hid_proj_type == "linear":
               UpperCAmelCase__								=  nn.Linear(lowerCamelCase__	,  lowerCamelCase__		)
         else:
               raise ValueError(f"""unsupported encoder_hid_proj_type: {encoder_hid_proj_type}"""		)

         UpperCAmelCase__								=  nn.Parameter(torch.zeros(1	,  num_embeddings + additional_embeddings	,  lowerCamelCase__		)		)

         if added_emb_type == "prd":
               UpperCAmelCase__								=  nn.Parameter(torch.zeros(1	,  1	,  lowerCamelCase__		)		)
         elif added_emb_type is None:
               UpperCAmelCase__								=  None
         else:
               raise ValueError(
                   f"""`added_emb_type`: {added_emb_type} is not supported. Make sure to choose one of `'prd'` or `None`."""		)

         UpperCAmelCase__								=  nn.ModuleList(
             [
                 BasicTransformerBlock(
                     lowerCamelCase__	,  lowerCamelCase__	,  lowerCamelCase__	,  dropout=lowerCamelCase__	,  activation_fn="gelu"	,  attention_bias=lowerCamelCase__	,  )
                 for d in range(lowerCamelCase__		)
             ]		)

         if norm_in_type == "layer":
               UpperCAmelCase__								=  nn.LayerNorm(lowerCamelCase__		)
         elif norm_in_type is None:
               UpperCAmelCase__								=  None
         else:
               raise ValueError(f"""Unsupported norm_in_type: {norm_in_type}."""		)

         UpperCAmelCase__								=  nn.LayerNorm(lowerCamelCase__		)

         UpperCAmelCase__								=  nn.Linear(lowerCamelCase__	,  lowerCamelCase__		)

         UpperCAmelCase__								=  torch.full(
             [num_embeddings + additional_embeddings, num_embeddings + additional_embeddings]	,  -1_0_0_0_0.0		)
         causal_attention_mask.triu_(1		)
         UpperCAmelCase__								=  causal_attention_mask[None, ...]
         self.register_buffer("causal_attention_mask"	,  lowerCamelCase__	,  persistent=lowerCamelCase__		)

         UpperCAmelCase__								=  nn.Parameter(torch.zeros(1	,  lowerCamelCase__		)		)
         UpperCAmelCase__								=  nn.Parameter(torch.zeros(1	,  lowerCamelCase__		)		)


   @property
   # Copied from diffusers.models.unet_2d_condition.UNet2DConditionModel.attn_processors
   def       lowercase_				(self					:						Any		)						->    Tuple:
         """simple docstring"""



         UpperCAmelCase__								=  {}

         def fn_recursive_add_processors(__UpperCAmelCase					:						Union[str, Any]	,  __UpperCAmelCase					:						Optional[int]	,  __UpperCAmelCase					:						List[str]		):
               if hasattr(lowerCamelCase__	,  "set_processor"		):
                     UpperCAmelCase__								=  module.processor

               for sub_name, child in module.named_children():
                     fn_recursive_add_processors(f"""{name}.{sub_name}"""	,  lowerCamelCase__	,  lowerCamelCase__		)

               return processors

         for name, module in self.named_children():
               fn_recursive_add_processors(lowerCamelCase__	,  lowerCamelCase__	,  lowerCamelCase__		)

         return processors


   def       lowercase_				(self					:						Any	,  __UpperCAmelCase					:						Optional[Any]		)						->    Tuple:
         """simple docstring"""



         UpperCAmelCase__								=  len(self.attn_processors.keys()		)

         if isinstance(lowerCamelCase__	,  lowerCamelCase__		) and len(lowerCamelCase__		) != count:
               raise ValueError(
                   f"""A dict of processors was passed, but the number of processors {len(lowerCamelCase__		)} does not match the"""
                   f""" number of attention layers: {count}. Please make sure to pass {count} processor classes."""		)

         def fn_recursive_attn_processor(__UpperCAmelCase					:						Optional[int]	,  __UpperCAmelCase					:						Optional[int]	,  __UpperCAmelCase					:						Optional[int]		):
               if hasattr(lowerCamelCase__	,  "set_processor"		):
                     if not isinstance(lowerCamelCase__	,  lowerCamelCase__		):
                           module.set_processor(lowerCamelCase__		)
                     else:
                           module.set_processor(processor.pop(f"""{name}.processor"""		)		)

               for sub_name, child in module.named_children():
                     fn_recursive_attn_processor(f"""{name}.{sub_name}"""	,  lowerCamelCase__	,  lowerCamelCase__		)

         for name, module in self.named_children():
               fn_recursive_attn_processor(lowerCamelCase__	,  lowerCamelCase__	,  lowerCamelCase__		)


   def       lowercase_				(self					:						Tuple		)						->    Dict:
         """simple docstring"""



         self.set_attn_processor(AttnProcessor()		)


   def       lowercase_				(self					:						Tuple	,  __UpperCAmelCase					:						Any	,  __UpperCAmelCase					:						List[str]	,  __UpperCAmelCase					:						Any	,  __UpperCAmelCase					:						Optional[int] = None	,  __UpperCAmelCase					:						List[Any] = None	,  __UpperCAmelCase					:						Tuple = True	,  )						->    List[str]:
         """simple docstring"""



         UpperCAmelCase__								=  hidden_states.shape[0]

         UpperCAmelCase__								=  timestep
         if not torch.is_tensor(lowerCamelCase__		):
               UpperCAmelCase__								=  torch.tensor([timesteps]	,  dtype=torch.long	,  device=hidden_states.device		)
         elif torch.is_tensor(lowerCamelCase__		) and len(timesteps.shape		) == 0:
               UpperCAmelCase__								=  timesteps[None].to(hidden_states.device		)

         # broadcast to batch dimension in a way that's compatible with ONNX/Core ML
         UpperCAmelCase__								=  timesteps * torch.ones(lowerCamelCase__	,  dtype=timesteps.dtype	,  device=timesteps.device		)

         UpperCAmelCase__								=  self.time_proj(lowerCamelCase__		)

         # timesteps does not contain any weights and will always return f32 tensors
         # but time_embedding might be fp16, so we need to cast here.
         UpperCAmelCase__								=  timesteps_projected.to(dtype=self.dtype		)
         UpperCAmelCase__								=  self.time_embedding(lowerCamelCase__		)

         if self.embedding_proj_norm is not None:
               UpperCAmelCase__								=  self.embedding_proj_norm(lowerCamelCase__		)

         UpperCAmelCase__								=  self.embedding_proj(lowerCamelCase__		)
         if self.encoder_hidden_states_proj is not None and encoder_hidden_states is not None:
               UpperCAmelCase__								=  self.encoder_hidden_states_proj(lowerCamelCase__		)
         elif self.encoder_hidden_states_proj is not None and encoder_hidden_states is None:
               raise ValueError("`encoder_hidden_states_proj` requires `encoder_hidden_states` to be set"		)

         UpperCAmelCase__								=  self.proj_in(lowerCamelCase__		)

         UpperCAmelCase__								=  self.positional_embedding.to(hidden_states.dtype		)

         UpperCAmelCase__								=  []
         UpperCAmelCase__								=  0

         if encoder_hidden_states is not None:
               additional_embeds.append(lowerCamelCase__		)
               additional_embeddings_len += encoder_hidden_states.shape[1]

         if len(proj_embeddings.shape		) == 2:
               UpperCAmelCase__								=  proj_embeddings[:, None, :]

         if len(hidden_states.shape		) == 2:
               UpperCAmelCase__								=  hidden_states[:, None, :]

         UpperCAmelCase__								=  additional_embeds + [
             proj_embeddings,
             time_embeddings[:, None, :],
             hidden_states,
         ]

         if self.prd_embedding is not None:
               UpperCAmelCase__								=  self.prd_embedding.to(hidden_states.dtype		).expand(lowerCamelCase__	,  -1	,  -1		)
               additional_embeds.append(lowerCamelCase__		)

         UpperCAmelCase__								=  torch.cat(
             lowerCamelCase__	,  dim=1	,  )

         # Allow positional_embedding to not include the `addtional_embeddings` and instead pad it with zeros for these additional tokens
         UpperCAmelCase__								=  additional_embeddings_len + proj_embeddings.shape[1] + 1
         if positional_embeddings.shape[1] < hidden_states.shape[1]:
               UpperCAmelCase__								=  F.pad(
                   lowerCamelCase__	,  (
                       0,
                       0,
                       additional_embeddings_len,
                       self.prd_embedding.shape[1] if self.prd_embedding is not None else 0,
                   )	,  value=0.0	,  )

         UpperCAmelCase__								=  hidden_states + positional_embeddings

         if attention_mask is not None:
               UpperCAmelCase__								=  (1 - attention_mask.to(hidden_states.dtype		)) * -1_0_0_0_0.0
               UpperCAmelCase__								=  F.pad(lowerCamelCase__	,  (0, self.additional_embeddings)	,  value=0.0		)
               UpperCAmelCase__								=  (attention_mask[:, None, :] + self.causal_attention_mask).to(hidden_states.dtype		)
               UpperCAmelCase__								=  attention_mask.repeat_interleave(self.config.num_attention_heads	,  dim=0		)

         if self.norm_in is not None:
               UpperCAmelCase__								=  self.norm_in(lowerCamelCase__		)

         for block in self.transformer_blocks:
               UpperCAmelCase__								=  block(lowerCamelCase__	,  attention_mask=lowerCamelCase__		)

         UpperCAmelCase__								=  self.norm_out(lowerCamelCase__		)

         if self.prd_embedding is not None:
               UpperCAmelCase__								=  hidden_states[:, -1]
         else:
               UpperCAmelCase__								=  hidden_states[:, additional_embeddings_len:]

         UpperCAmelCase__								=  self.proj_to_clip_embeddings(lowerCamelCase__		)

         if not return_dict:
               return (predicted_image_embedding,)

         return PriorTransformerOutput(predicted_image_embedding=lowerCamelCase__		)





   def       lowercase_				(self					:						Tuple	,  __UpperCAmelCase					:						Any		)						->    List[Any]:
         """simple docstring"""



         UpperCAmelCase__								=  (prior_latents * self.clip_std) + self.clip_mean
         return prior_latents




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 					A							(    UpperCAmelCase_					):


   def __init__(self					:						Union[str, Any]	,  __UpperCAmelCase					:						AutoencoderKL	,  __UpperCAmelCase					:						CLIPTextModel	,  __UpperCAmelCase					:						CLIPTokenizer	,  __UpperCAmelCase					:						UNetaDConditionModel	,  __UpperCAmelCase					:						Union[DDIMScheduler, PNDMScheduler, LMSDiscreteScheduler]	,  __UpperCAmelCase					:						StableDiffusionSafetyChecker	,  __UpperCAmelCase					:						CLIPImageProcessor	,  __UpperCAmelCase					:						bool = True	,  )						->    Tuple:
         """simple docstring"""



         super()._init_()

         UpperCAmelCase__								=  StableDiffusionPipeline.from_pretrained(__UpperCAmelCase		)
         UpperCAmelCase__								=  StableDiffusionPipeline.from_pretrained(__UpperCAmelCase		)
         UpperCAmelCase__								=  StableDiffusionPipeline.from_pretrained(__UpperCAmelCase		)
         UpperCAmelCase__								=  StableDiffusionPipeline(
             vae=__UpperCAmelCase	,  text_encoder=__UpperCAmelCase	,  tokenizer=__UpperCAmelCase	,  unet=__UpperCAmelCase	,  scheduler=__UpperCAmelCase	,  safety_checker=__UpperCAmelCase	,  feature_extractor=__UpperCAmelCase	,  requires_safety_checker=__UpperCAmelCase	,  )

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


   @property
   def       lowercase_				(self					:						int		)						->    Dict[str, Any]:
         """simple docstring"""



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


   def       lowercase_				(self					:						Union[str, Any]	,  __UpperCAmelCase					:						Optional[Union[str, int]] = "auto"		)						->    Optional[int]:
         """simple docstring"""



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


   def       lowercase_				(self					:						int		)						->    Optional[int]:
         """simple docstring"""



         self.enable_attention_slicing(__UpperCAmelCase		)


   @torch.no_grad()
   def       lowercase_				(self					:						Optional[int]	,  __UpperCAmelCase					:						Union[str, List[str]]	,  __UpperCAmelCase					:						int = 5_1_2	,  __UpperCAmelCase					:						int = 5_1_2	,  __UpperCAmelCase					:						int = 5_0	,  __UpperCAmelCase					:						float = 7.5	,  __UpperCAmelCase					:						Optional[Union[str, List[str]]] = None	,  __UpperCAmelCase					:						Optional[int] = 1	,  __UpperCAmelCase					:						float = 0.0	,  __UpperCAmelCase					:						Optional[torch.Generator] = None	,  __UpperCAmelCase					:						Optional[torch.FloatTensor] = None	,  __UpperCAmelCase					:						Optional[str] = "pil"	,  __UpperCAmelCase					:						bool = True	,  __UpperCAmelCase					:						Optional[Callable[[int, int, torch.FloatTensor], None]] = None	,  __UpperCAmelCase					:						int = 1	,  **__UpperCAmelCase					:						Any	,  )						->    Dict:
         """simple docstring"""



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


   @torch.no_grad()
   def       lowercase_				(self					:						List[str]	,  __UpperCAmelCase					:						Union[str, List[str]]	,  __UpperCAmelCase					:						int = 5_1_2	,  __UpperCAmelCase					:						int = 5_1_2	,  __UpperCAmelCase					:						int = 5_0	,  __UpperCAmelCase					:						float = 7.5	,  __UpperCAmelCase					:						Optional[Union[str, List[str]]] = None	,  __UpperCAmelCase					:						Optional[int] = 1	,  __UpperCAmelCase					:						float = 0.0	,  __UpperCAmelCase					:						Optional[torch.Generator] = None	,  __UpperCAmelCase					:						Optional[torch.FloatTensor] = None	,  __UpperCAmelCase					:						Optional[str] = "pil"	,  __UpperCAmelCase					:						bool = True	,  __UpperCAmelCase					:						Optional[Callable[[int, int, torch.FloatTensor], None]] = None	,  __UpperCAmelCase					:						int = 1	,  **__UpperCAmelCase					:						Optional[Any]	,  )						->    Any:
         """simple docstring"""



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


   @torch.no_grad()
   def       lowercase_				(self					:						List[str]	,  __UpperCAmelCase					:						Union[str, List[str]]	,  __UpperCAmelCase					:						int = 5_1_2	,  __UpperCAmelCase					:						int = 5_1_2	,  __UpperCAmelCase					:						int = 5_0	,  __UpperCAmelCase					:						float = 7.5	,  __UpperCAmelCase					:						Optional[Union[str, List[str]]] = None	,  __UpperCAmelCase					:						Optional[int] = 1	,  __UpperCAmelCase					:						float = 0.0	,  __UpperCAmelCase					:						Optional[torch.Generator] = None	,  __UpperCAmelCase					:						Optional[torch.FloatTensor] = None	,  __UpperCAmelCase					:						Optional[str] = "pil"	,  __UpperCAmelCase					:						bool = True	,  __UpperCAmelCase					:						Optional[Callable[[int, int, torch.FloatTensor], None]] = None	,  __UpperCAmelCase					:						int = 1	,  **__UpperCAmelCase					:						Any	,  )						->    Dict:
         """simple docstring"""



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


   @torch.no_grad()
   def       lowercase_				(self					:						Union[str, Any]	,  __UpperCAmelCase					:						Union[str, List[str]]	,  __UpperCAmelCase					:						int = 5_1_2	,  __UpperCAmelCase					:						int = 5_1_2	,  __UpperCAmelCase					:						int = 5_0	,  __UpperCAmelCase					:						float = 7.5	,  __UpperCAmelCase					:						Optional[Union[str, List[str]]] = None	,  __UpperCAmelCase					:						Optional[int] = 1	,  __UpperCAmelCase					:						float = 0.0	,  __UpperCAmelCase					:						Optional[torch.Generator] = None	,  __UpperCAmelCase					:						Optional[torch.FloatTensor] = None	,  __UpperCAmelCase					:						Optional[str] = "pil"	,  __UpperCAmelCase					:						bool = True	,  __UpperCAmelCase					:						Optional[Callable[[int, int, torch.FloatTensor], None]] = None	,  __UpperCAmelCase					:						int = 1	,  **__UpperCAmelCase					:						Union[str, Any]	,  )						->    List[str]:
         """simple docstring"""



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





   @torch.no_grad()
   def       lowercase_				(self					:						int	,  __UpperCAmelCase					:						Union[str, List[str]]	,  __UpperCAmelCase					:						int = 5_1_2	,  __UpperCAmelCase					:						int = 5_1_2	,  __UpperCAmelCase					:						int = 5_0	,  __UpperCAmelCase					:						float = 7.5	,  __UpperCAmelCase					:						Optional[Union[str, List[str]]] = None	,  __UpperCAmelCase					:						Optional[int] = 1	,  __UpperCAmelCase					:						float = 0.0	,  __UpperCAmelCase					:						Optional[torch.Generator] = None	,  __UpperCAmelCase					:						Optional[torch.FloatTensor] = None	,  __UpperCAmelCase					:						Optional[str] = "pil"	,  __UpperCAmelCase					:						bool = True	,  __UpperCAmelCase					:						Optional[Callable[[int, int, torch.FloatTensor], None]] = None	,  __UpperCAmelCase					:						int = 1	,  **__UpperCAmelCase					:						Any	,  )						->    Union[str, Any]:
         """simple docstring"""



         UpperCAmelCase__								=  "cuda" if torch.cuda.is_available() else "cpu"
         self.to(__UpperCAmelCase		)

         # 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
         UpperCAmelCase__								=  self.textaimg_sda_a(
             prompt=__UpperCAmelCase	,  height=__UpperCAmelCase	,  width=__UpperCAmelCase	,  num_inference_steps=__UpperCAmelCase	,  guidance_scale=__UpperCAmelCase	,  negative_prompt=__UpperCAmelCase	,  num_images_per_prompt=__UpperCAmelCase	,  eta=__UpperCAmelCase	,  generator=__UpperCAmelCase	,  latents=__UpperCAmelCase	,  output_type=__UpperCAmelCase	,  return_dict=__UpperCAmelCase	,  callback=__UpperCAmelCase	,  callback_steps=__UpperCAmelCase	,  **__UpperCAmelCase	,  )

         # Get first result from Stable Diffusion Checkpoint v1.2
         UpperCAmelCase__								=  self.textaimg_sda_a(
             prompt=__UpperCAmelCase	,  height=__UpperCAmelCase	,  width=__UpperCAmelCase	,  num_inference_steps=__UpperCAmelCase	,  guidance_scale=__UpperCAmelCase	,  negative_prompt=__UpperCAmelCase	,  num_images_per_prompt=__UpperCAmelCase	,  eta=__UpperCAmelCase	,  generator=__UpperCAmelCase	,  latents=__UpperCAmelCase	,  output_type=__UpperCAmelCase	,  return_dict=__UpperCAmelCase	,  callback=__UpperCAmelCase	,  callback_steps=__UpperCAmelCase	,  **__UpperCAmelCase	,  )

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

         # Get first result from Stable Diffusion Checkpoint v1.4
         UpperCAmelCase__								=  self.textaimg_sda_a(
             prompt=__UpperCAmelCase	,  height=__UpperCAmelCase	,  width=__UpperCAmelCase	,  num_inference_steps=__UpperCAmelCase	,  guidance_scale=__UpperCAmelCase	,  negative_prompt=__UpperCAmelCase	,  num_images_per_prompt=__UpperCAmelCase	,  eta=__UpperCAmelCase	,  generator=__UpperCAmelCase	,  latents=__UpperCAmelCase	,  output_type=__UpperCAmelCase	,  return_dict=__UpperCAmelCase	,  callback=__UpperCAmelCase	,  callback_steps=__UpperCAmelCase	,  **__UpperCAmelCase	,  )

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



