"""simple docstring"""





import argparse
import collections

import torch
from flax import traverse_util
from tax import checkpoints

from transformers import TaConfig, TaEncoderModel, TaForConditionalGeneration
from transformers.utils import logging


logging.set_verbosity_info()


def    lowercase_   (   _lowerCamelCase:	Any						,   _lowerCamelCase:	List[Any]						,   _lowerCamelCase:	Optional[int]						,   _lowerCamelCase:	str="attention"      ) ->      Tuple:



							'''simple docstring'''

							__lowerCamelCase					:		str		   =     params[F"""{prefix}/layers_{i}/{layer_name}/key/kernel"""]
							__lowerCamelCase					:		Any		   =     params[F"""{prefix}/layers_{i}/{layer_name}/out/kernel"""]
							__lowerCamelCase					:		int		   =     params[F"""{prefix}/layers_{i}/{layer_name}/query/kernel"""]
							__lowerCamelCase					:		Any		   =     params[F"""{prefix}/layers_{i}/{layer_name}/value/kernel"""]
							return k, o, q, v


def    lowercase_   (   _lowerCamelCase:	int						,   _lowerCamelCase:	Dict						,   _lowerCamelCase:	Dict						,   _lowerCamelCase:	Optional[int]=False      ) ->      Optional[int]:



							'''simple docstring'''

							if split_mlp_wi:
														__lowerCamelCase					:		Optional[int]		   =     params[F"""{prefix}/layers_{i}/mlp/wi_0/kernel"""]
														__lowerCamelCase					:		Dict		   =     params[F"""{prefix}/layers_{i}/mlp/wi_1/kernel"""]
														__lowerCamelCase					:		int		   =     (wi_a, wi_a)
							else:
														__lowerCamelCase					:		Optional[Any]		   =     params[F"""{prefix}/layers_{i}/mlp/wi/kernel"""]

							__lowerCamelCase					:		str		   =     params[F"""{prefix}/layers_{i}/mlp/wo/kernel"""]
							return wi, wo


def    lowercase_   (   _lowerCamelCase:	Union[str, Any]						,   _lowerCamelCase:	Union[str, Any]						,   _lowerCamelCase:	List[str]						,   _lowerCamelCase:	Any      ) ->      Optional[Any]:



							'''simple docstring'''

							return params[F"""{prefix}/layers_{i}/{layer_name}/scale"""]


def    lowercase_   (   _lowerCamelCase:	dict						,   *, _lowerCamelCase:	int						,   _lowerCamelCase:	bool      ) ->      Optional[int]:



							'''simple docstring'''

							__lowerCamelCase					:		str		   =     traverse_util.flatten_dict(variables["target"]      )
							__lowerCamelCase					:		Optional[Any]		   =     {"/".join(_lowerCamelCase      ): v for k, v in old.items()}

							# v1.1 models have a gated GeLU with wi_0 and wi_1 instead of wi
							__lowerCamelCase					:		Optional[int]		   =     "encoder/layers_0/mlp/wi_0/kernel" in old
							print("Split MLP:"						,   _lowerCamelCase      )

							__lowerCamelCase					:		Union[str, Any]		   =     collections.OrderedDict()

							# Shared embeddings.
							__lowerCamelCase					:		Optional[int]		   =     old["token_embedder/embedding"]

							# Encoder.
							for i in range(_lowerCamelCase      ):
														# Block i, layer 0 (Self Attention).
														__lowerCamelCase					:		Any		   =     tax_layer_norm_lookup(_lowerCamelCase						,   _lowerCamelCase						,   "encoder"						,   "pre_attention_layer_norm"      )
														__lowerCamelCase   ,  __lowerCamelCase   ,  __lowerCamelCase   ,  __lowerCamelCase					:		List[str]		   =     tax_attention_lookup(_lowerCamelCase						,   _lowerCamelCase						,   "encoder"						,   "attention"      )
														__lowerCamelCase					:		Optional[int]		   =     layer_norm
														__lowerCamelCase					:		int		   =     k.T
														__lowerCamelCase					:		Optional[int]		   =     o.T
														__lowerCamelCase					:		Tuple		   =     q.T
														__lowerCamelCase					:		List[str]		   =     v.T

														# Block i, layer 1 (MLP).
														__lowerCamelCase					:		str		   =     tax_layer_norm_lookup(_lowerCamelCase						,   _lowerCamelCase						,   "encoder"						,   "pre_mlp_layer_norm"      )
														__lowerCamelCase   ,  __lowerCamelCase					:		List[str]		   =     tax_mlp_lookup(_lowerCamelCase						,   _lowerCamelCase						,   "encoder"						,   _lowerCamelCase      )
														__lowerCamelCase					:		List[Any]		   =     layer_norm
														if split_mlp_wi:
																					__lowerCamelCase					:		Dict		   =     wi[0].T
																					__lowerCamelCase					:		Tuple		   =     wi[1].T
														else:
																					__lowerCamelCase					:		str		   =     wi.T
														__lowerCamelCase					:		int		   =     wo.T

							__lowerCamelCase					:		Optional[int]		   =     old[
							    "encoder/relpos_bias/rel_embedding"
							].T
							__lowerCamelCase					:		Tuple		   =     old["encoder/encoder_norm/scale"]

							if not is_encoder_only:
														# Decoder.
														for i in range(_lowerCamelCase      ):
																					# Block i, layer 0 (Self Attention).
																					__lowerCamelCase					:		Optional[int]		   =     tax_layer_norm_lookup(_lowerCamelCase						,   _lowerCamelCase						,   "decoder"						,   "pre_self_attention_layer_norm"      )
																					__lowerCamelCase   ,  __lowerCamelCase   ,  __lowerCamelCase   ,  __lowerCamelCase					:		Dict		   =     tax_attention_lookup(_lowerCamelCase						,   _lowerCamelCase						,   "decoder"						,   "self_attention"      )
																					__lowerCamelCase					:		int		   =     layer_norm
																					__lowerCamelCase					:		Dict		   =     k.T
																					__lowerCamelCase					:		Dict		   =     o.T
																					__lowerCamelCase					:		Union[str, Any]		   =     q.T
																					__lowerCamelCase					:		Optional[int]		   =     v.T

																					# Block i, layer 1 (Cross Attention).
																					__lowerCamelCase					:		Dict		   =     tax_layer_norm_lookup(_lowerCamelCase						,   _lowerCamelCase						,   "decoder"						,   "pre_cross_attention_layer_norm"      )
																					__lowerCamelCase   ,  __lowerCamelCase   ,  __lowerCamelCase   ,  __lowerCamelCase					:		Tuple		   =     tax_attention_lookup(_lowerCamelCase						,   _lowerCamelCase						,   "decoder"						,   "encoder_decoder_attention"      )
																					__lowerCamelCase					:		Optional[Any]		   =     layer_norm
																					__lowerCamelCase					:		Dict		   =     k.T
																					__lowerCamelCase					:		Tuple		   =     o.T
																					__lowerCamelCase					:		Optional[int]		   =     q.T
																					__lowerCamelCase					:		Optional[Any]		   =     v.T

																					# Block i, layer 2 (MLP).
																					__lowerCamelCase					:		int		   =     tax_layer_norm_lookup(_lowerCamelCase						,   _lowerCamelCase						,   "decoder"						,   "pre_mlp_layer_norm"      )
																					__lowerCamelCase   ,  __lowerCamelCase					:		List[Any]		   =     tax_mlp_lookup(_lowerCamelCase						,   _lowerCamelCase						,   "decoder"						,   _lowerCamelCase      )
																					__lowerCamelCase					:		Any		   =     layer_norm
																					if split_mlp_wi:
																												__lowerCamelCase					:		Union[str, Any]		   =     wi[0].T
																												__lowerCamelCase					:		Optional[Any]		   =     wi[1].T
																					else:
																												__lowerCamelCase					:		Dict		   =     wi.T
																					__lowerCamelCase					:		List[Any]		   =     wo.T

														__lowerCamelCase					:		Optional[Any]		   =     old["decoder/decoder_norm/scale"]
														__lowerCamelCase					:		int		   =     old[
														    "decoder/relpos_bias/rel_embedding"
														].T

														# LM Head (only in v1.1 checkpoints, in v1.0 embeddings are used instead)
														if "decoder/logits_dense/kernel" in old:
																					__lowerCamelCase					:		Optional[int]		   =     old["decoder/logits_dense/kernel"].T

							return new


def    lowercase_   (   _lowerCamelCase:	Any						,   _lowerCamelCase:	bool      ) ->      str:



							'''simple docstring'''

							__lowerCamelCase					:		Any		   =     collections.OrderedDict([(k, torch.from_numpy(v.copy()      )) for (k, v) in converted_params.items()]      )

							# Add what is missing.
							if "encoder.embed_tokens.weight" not in state_dict:
														__lowerCamelCase					:		Dict		   =     state_dict["shared.weight"]

							if not is_encoder_only:
														if "decoder.embed_tokens.weight" not in state_dict:
																					__lowerCamelCase					:		List[str]		   =     state_dict["shared.weight"]

														if "lm_head.weight" not in state_dict:  # For old 1.0 models.
																					print("Using shared word embeddings as lm_head."      )
																					__lowerCamelCase					:		List[Any]		   =     state_dict["shared.weight"]

							return state_dict


def    lowercase_   (   _lowerCamelCase:	Tuple						,   _lowerCamelCase:	str						,   _lowerCamelCase:	List[Any]						,   _lowerCamelCase:	List[str]      ) ->      Union[str, Any]:



							'''simple docstring'''

							__lowerCamelCase					:		str		   =     checkpoints.load_tax_checkpoint(_lowerCamelCase      )
							__lowerCamelCase					:		List[str]		   =     convert_tax_to_pytorch(_lowerCamelCase						,   num_layers=config.num_layers						,   is_encoder_only=_lowerCamelCase      )
							__lowerCamelCase					:		str		   =     make_state_dict(_lowerCamelCase						,   _lowerCamelCase      )
							model.load_state_dict(_lowerCamelCase						,   strict=_lowerCamelCase      )


def    lowercase_   (   _lowerCamelCase:	Union[str, Any]						,   _lowerCamelCase:	Optional[int]						,   _lowerCamelCase:	List[Any]						,   _lowerCamelCase:	bool = False      ) ->      Any:



							'''simple docstring'''

							__lowerCamelCase					:		Dict		   =     TaConfig.from_json_file(_lowerCamelCase      )
							print(F"""Building PyTorch model from configuration: {config}"""      )
							# Non-v1.1 checkpoints could also use T5Model, but this works for all.
							# The v1.0 checkpoints will simply have an LM head that is the word embeddings.
							if is_encoder_only:
														__lowerCamelCase					:		Union[str, Any]		   =     TaEncoderModel(_lowerCamelCase      )
							else:
														__lowerCamelCase					:		List[str]		   =     TaForConditionalGeneration(_lowerCamelCase      )

							# Load weights from tf checkpoint
							load_tax_weights_in_ta(_lowerCamelCase						,   _lowerCamelCase						,   _lowerCamelCase						,   _lowerCamelCase      )

							# Save pytorch-model
							print(F"""Save PyTorch model to {pytorch_dump_path}"""      )
							model.save_pretrained(_lowerCamelCase      )

							# Verify that we can load the checkpoint.
							model.from_pretrained(_lowerCamelCase      )
							print("Done"      )


if __name__ == "__main__":
				__A  =				argparse.ArgumentParser(description='''Converts a native T5X checkpoint into a PyTorch checkpoint.''')
				# Required parameters
				parser.add_argument(
				    '''--t5x_checkpoint_path''', default=None, type=str, required=True, help='''Path to the T5X checkpoint.'''
				)
				parser.add_argument(
				    '''--config_file''',
				    default=None,
				    type=str,
				    required=True,
				    help='''The config json file corresponding to the pre-trained T5 model.\nThis specifies the model architecture.''',
				)
				parser.add_argument(
				    '''--pytorch_dump_path''', default=None, type=str, required=True, help='''Path to the output PyTorch model.'''
				)
				parser.add_argument(
				    '''--is_encoder_only''', action='''store_true''', help='''Check if the model is encoder-decoder model''', default=False
				)
				__A  =				parser.parse_args()
				convert_tax_checkpoint_to_pytorch(
				    args.tax_checkpoint_path, args.config_file, args.pytorch_dump_path, args.is_encoder_only
				)
"""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


__A  =				'''CompVis/stable-diffusion-v1-1'''
__A  =				'''CompVis/stable-diffusion-v1-2'''
__A  =				'''CompVis/stable-diffusion-v1-3'''
__A  =				'''CompVis/stable-diffusion-v1-4'''
class  _snake_case     (					a__		):






						def __init__(       self      :			int							,					UpperCAmelCase      :			AutoencoderKL							,					UpperCAmelCase      :			CLIPTextModel							,					UpperCAmelCase      :			CLIPTokenizer							,					UpperCAmelCase      :			UNetaDConditionModel							,					UpperCAmelCase      :			Union[DDIMScheduler, PNDMScheduler, LMSDiscreteScheduler]							,					UpperCAmelCase      :			StableDiffusionSafetyChecker							,					UpperCAmelCase      :			CLIPImageProcessor							,					UpperCAmelCase      :			bool = True							,					):
													super()._init_()

													__lowerCamelCase					:		Optional[int]		   =     StableDiffusionPipeline.from_pretrained(UpperCAmelCase    )
													__lowerCamelCase					:		Optional[int]		   =     StableDiffusionPipeline.from_pretrained(UpperCAmelCase    )
													__lowerCamelCase					:		Tuple		   =     StableDiffusionPipeline.from_pretrained(UpperCAmelCase    )
													__lowerCamelCase					:		List[str]		   =     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       lowerCamelCase__     (       self      :			Dict    ):
													return {k: getattr(self							,					UpperCAmelCase    ) for k in self.config.keys() if not k.startswith("_"    )}






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






						def       lowerCamelCase__     (       self      :			Tuple    ):
													self.enable_attention_slicing(UpperCAmelCase    )






						@torch.no_grad()
						def       lowerCamelCase__     (       self      :			Dict							,					UpperCAmelCase      :			Union[str, List[str]]							,					UpperCAmelCase      :			int = 512							,					UpperCAmelCase      :			int = 512							,					UpperCAmelCase      :			int = 50							,					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]							,					):
													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       lowerCamelCase__     (       self      :			Dict							,					UpperCAmelCase      :			Union[str, List[str]]							,					UpperCAmelCase      :			int = 512							,					UpperCAmelCase      :			int = 512							,					UpperCAmelCase      :			int = 50							,					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]							,					):
													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       lowerCamelCase__     (       self      :			Tuple							,					UpperCAmelCase      :			Union[str, List[str]]							,					UpperCAmelCase      :			int = 512							,					UpperCAmelCase      :			int = 512							,					UpperCAmelCase      :			int = 50							,					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      :			Dict							,					):
													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       lowerCamelCase__     (       self      :			Optional[Any]							,					UpperCAmelCase      :			Union[str, List[str]]							,					UpperCAmelCase      :			int = 512							,					UpperCAmelCase      :			int = 512							,					UpperCAmelCase      :			int = 50							,					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      :			List[str]							,					):
													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       lowerCamelCase__     (       self      :			str							,					UpperCAmelCase      :			Union[str, List[str]]							,					UpperCAmelCase      :			int = 512							,					UpperCAmelCase      :			int = 512							,					UpperCAmelCase      :			int = 50							,					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      :			Tuple							,					):
													__lowerCamelCase					:		Optional[int]		   =     "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
													__lowerCamelCase					:		str		   =     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
													__lowerCamelCase					:		Optional[int]		   =     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
													__lowerCamelCase					:		Any		   =     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
													__lowerCamelCase					:		Optional[Any]		   =     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]]    )