"""simple docstring"""




import argparse
import json
import os

import numpy as np
import PIL
import requests
import tensorflow.keras.applications.efficientnet as efficientnet
import torch
from huggingface_hub import hf_hub_download
from PIL import Image
from tensorflow.keras.preprocessing import image

from transformers import (
    EfficientNetConfig,
    EfficientNetForImageClassification,
    EfficientNetImageProcessor,
)
from transformers.utils import logging


logging.set_verbosity_info()
__lowerCAmelCase     :				Dict    				=    logging.get_logger(__name__)

__lowerCAmelCase     :				Union[str, Any]    				=    {
    "b0": efficientnet.EfficientNetBa,
    "b1": efficientnet.EfficientNetBa,
    "b2": efficientnet.EfficientNetBa,
    "b3": efficientnet.EfficientNetBa,
    "b4": efficientnet.EfficientNetBa,
    "b5": efficientnet.EfficientNetBa,
    "b6": efficientnet.EfficientNetBa,
    "b7": efficientnet.EfficientNetBa,
}

__lowerCAmelCase     :				Tuple    				=    {
    "b0": {
        "hidden_dim": 12_80,
        "width_coef": 1.0,
        "depth_coef": 1.0,
        "image_size": 2_24,
        "dropout_rate": 0.2,
        "dw_padding": [],
    },
    "b1": {
        "hidden_dim": 12_80,
        "width_coef": 1.0,
        "depth_coef": 1.1,
        "image_size": 2_40,
        "dropout_rate": 0.2,
        "dw_padding": [16],
    },
    "b2": {
        "hidden_dim": 14_08,
        "width_coef": 1.1,
        "depth_coef": 1.2,
        "image_size": 2_60,
        "dropout_rate": 0.3,
        "dw_padding": [5, 8, 16],
    },
    "b3": {
        "hidden_dim": 15_36,
        "width_coef": 1.2,
        "depth_coef": 1.4,
        "image_size": 3_00,
        "dropout_rate": 0.3,
        "dw_padding": [5, 18],
    },
    "b4": {
        "hidden_dim": 17_92,
        "width_coef": 1.4,
        "depth_coef": 1.8,
        "image_size": 3_80,
        "dropout_rate": 0.4,
        "dw_padding": [6],
    },
    "b5": {
        "hidden_dim": 20_48,
        "width_coef": 1.6,
        "depth_coef": 2.2,
        "image_size": 4_56,
        "dropout_rate": 0.4,
        "dw_padding": [13, 27],
    },
    "b6": {
        "hidden_dim": 23_04,
        "width_coef": 1.8,
        "depth_coef": 2.6,
        "image_size": 5_28,
        "dropout_rate": 0.5,
        "dw_padding": [31],
    },
    "b7": {
        "hidden_dim": 25_60,
        "width_coef": 2.0,
        "depth_coef": 3.1,
        "image_size": 6_00,
        "dropout_rate": 0.5,
        "dw_padding": [18],
    },
}







def 				_UpperCAmelCase		(							lowerCamelCase__  ):





		"""simple docstring"""




		lowerCAmelCase__   = EfficientNetConfig()
		lowerCAmelCase__   = CONFIG_MAP[model_name]["""hidden_dim"""]
		lowerCAmelCase__   = CONFIG_MAP[model_name]["""width_coef"""]
		lowerCAmelCase__   = CONFIG_MAP[model_name]["""depth_coef"""]
		lowerCAmelCase__   = CONFIG_MAP[model_name]["""image_size"""]
		lowerCAmelCase__   = CONFIG_MAP[model_name]["""dropout_rate"""]
		lowerCAmelCase__   = CONFIG_MAP[model_name]["""dw_padding"""]

		lowerCAmelCase__   = """huggingface/label-files"""
		lowerCAmelCase__   = """imagenet-1k-id2label.json"""
		lowerCAmelCase__   = 1000
		lowerCAmelCase__   = json.load(open(hf_hub_download(lowerCamelCase__      ,	lowerCamelCase__      ,	repo_type="""dataset"""  )      ,	"""r"""  )  )
		lowerCAmelCase__   = {int(lowerCamelCase__  ): v for k, v in idalabel.items()}

		lowerCAmelCase__   = idalabel
		lowerCAmelCase__   = {v: k for k, v in idalabel.items()}
		return config







def 				_UpperCAmelCase		(							):





		"""simple docstring"""




		lowerCAmelCase__   = """http://images.cocodataset.org/val2017/000000039769.jpg"""
		lowerCAmelCase__   = Image.open(requests.get(lowerCamelCase__      ,	stream=lowerCamelCase__  ).raw  )
		return im







def 				_UpperCAmelCase		(							lowerCamelCase__  ):





		"""simple docstring"""




		lowerCAmelCase__   = CONFIG_MAP[model_name]["""image_size"""]
		lowerCAmelCase__   = EfficientNetImageProcessor(
		    size={"""height""": size, """width""": size}      ,	image_mean=[0.4_85, 0.4_56, 0.4_06]      ,	image_std=[0.47_85_39_44, 0.4_73_28_64, 0.47_43_41_63]      ,	do_center_crop=lowerCamelCase__      ,	)
		return preprocessor







def 				_UpperCAmelCase		(							lowerCamelCase__  ):





		"""simple docstring"""




		lowerCAmelCase__   = [v.split("""_"""  )[0].split("""block"""  )[1] for v in original_param_names if v.startswith("""block"""  )]
		lowerCAmelCase__   = sorted(set(lowerCamelCase__  )  )
		lowerCAmelCase__   = len(lowerCamelCase__  )
		lowerCAmelCase__   = {b: str(lowerCamelCase__  ) for b, i in zip(lowerCamelCase__      ,	range(lowerCamelCase__  )  )}

		lowerCAmelCase__   = []
		rename_keys.append(("""stem_conv/kernel:0""", """embeddings.convolution.weight""")  )
		rename_keys.append(("""stem_bn/gamma:0""", """embeddings.batchnorm.weight""")  )
		rename_keys.append(("""stem_bn/beta:0""", """embeddings.batchnorm.bias""")  )
		rename_keys.append(("""stem_bn/moving_mean:0""", """embeddings.batchnorm.running_mean""")  )
		rename_keys.append(("""stem_bn/moving_variance:0""", """embeddings.batchnorm.running_var""")  )

		for b in block_names:
				lowerCAmelCase__   = block_name_mapping[b]
				rename_keys.append((f"""block{b}_expand_conv/kernel:0""", f"""encoder.blocks.{hf_b}.expansion.expand_conv.weight""")  )
				rename_keys.append((f"""block{b}_expand_bn/gamma:0""", f"""encoder.blocks.{hf_b}.expansion.expand_bn.weight""")  )
				rename_keys.append((f"""block{b}_expand_bn/beta:0""", f"""encoder.blocks.{hf_b}.expansion.expand_bn.bias""")  )
				rename_keys.append(
				    (f"""block{b}_expand_bn/moving_mean:0""", f"""encoder.blocks.{hf_b}.expansion.expand_bn.running_mean""")  )
				rename_keys.append(
				    (f"""block{b}_expand_bn/moving_variance:0""", f"""encoder.blocks.{hf_b}.expansion.expand_bn.running_var""")  )
				rename_keys.append(
				    (f"""block{b}_dwconv/depthwise_kernel:0""", f"""encoder.blocks.{hf_b}.depthwise_conv.depthwise_conv.weight""")  )
				rename_keys.append((f"""block{b}_bn/gamma:0""", f"""encoder.blocks.{hf_b}.depthwise_conv.depthwise_norm.weight""")  )
				rename_keys.append((f"""block{b}_bn/beta:0""", f"""encoder.blocks.{hf_b}.depthwise_conv.depthwise_norm.bias""")  )
				rename_keys.append(
				    (f"""block{b}_bn/moving_mean:0""", f"""encoder.blocks.{hf_b}.depthwise_conv.depthwise_norm.running_mean""")  )
				rename_keys.append(
				    (f"""block{b}_bn/moving_variance:0""", f"""encoder.blocks.{hf_b}.depthwise_conv.depthwise_norm.running_var""")  )

				rename_keys.append((f"""block{b}_se_reduce/kernel:0""", f"""encoder.blocks.{hf_b}.squeeze_excite.reduce.weight""")  )
				rename_keys.append((f"""block{b}_se_reduce/bias:0""", f"""encoder.blocks.{hf_b}.squeeze_excite.reduce.bias""")  )
				rename_keys.append((f"""block{b}_se_expand/kernel:0""", f"""encoder.blocks.{hf_b}.squeeze_excite.expand.weight""")  )
				rename_keys.append((f"""block{b}_se_expand/bias:0""", f"""encoder.blocks.{hf_b}.squeeze_excite.expand.bias""")  )
				rename_keys.append(
				    (f"""block{b}_project_conv/kernel:0""", f"""encoder.blocks.{hf_b}.projection.project_conv.weight""")  )
				rename_keys.append((f"""block{b}_project_bn/gamma:0""", f"""encoder.blocks.{hf_b}.projection.project_bn.weight""")  )
				rename_keys.append((f"""block{b}_project_bn/beta:0""", f"""encoder.blocks.{hf_b}.projection.project_bn.bias""")  )
				rename_keys.append(
				    (f"""block{b}_project_bn/moving_mean:0""", f"""encoder.blocks.{hf_b}.projection.project_bn.running_mean""")  )
				rename_keys.append(
				    (f"""block{b}_project_bn/moving_variance:0""", f"""encoder.blocks.{hf_b}.projection.project_bn.running_var""")  )

		rename_keys.append(("""top_conv/kernel:0""", """encoder.top_conv.weight""")  )
		rename_keys.append(("""top_bn/gamma:0""", """encoder.top_bn.weight""")  )
		rename_keys.append(("""top_bn/beta:0""", """encoder.top_bn.bias""")  )
		rename_keys.append(("""top_bn/moving_mean:0""", """encoder.top_bn.running_mean""")  )
		rename_keys.append(("""top_bn/moving_variance:0""", """encoder.top_bn.running_var""")  )

		lowerCAmelCase__   = {}
		for item in rename_keys:
				if item[0] in original_param_names:
						lowerCAmelCase__   = """efficientnet.""" + item[1]

		lowerCAmelCase__   = """classifier.weight"""
		lowerCAmelCase__   = """classifier.bias"""
		return key_mapping







def 				_UpperCAmelCase		(							lowerCamelCase__      ,	lowerCamelCase__      ,	lowerCamelCase__  ):





		"""simple docstring"""




		for key, value in tf_params.items():
				if "normalization" in key:
						continue

				lowerCAmelCase__   = key_mapping[key]
				if "_conv" in key and "kernel" in key:
						lowerCAmelCase__   = torch.from_numpy(lowerCamelCase__  ).permute(3      ,	2      ,	0      ,	1  )
				elif "depthwise_kernel" in key:
						lowerCAmelCase__   = torch.from_numpy(lowerCamelCase__  ).permute(2      ,	3      ,	0      ,	1  )
				elif "kernel" in key:
						lowerCAmelCase__   = torch.from_numpy(np.transpose(lowerCamelCase__  )  )
				else:
						lowerCAmelCase__   = torch.from_numpy(lowerCamelCase__  )

				# Replace HF parameters with original TF model parameters
				assert hf_params[hf_key].shape == new_hf_value.shape
				hf_params[hf_key].copy_(lowerCamelCase__  )







@torch.no_grad()
def 				_UpperCAmelCase		(							lowerCamelCase__      ,	lowerCamelCase__      ,	lowerCamelCase__      ,	lowerCamelCase__  ):





		"""simple docstring"""




		lowerCAmelCase__   = model_classes[model_name](
		    include_top=lowerCamelCase__      ,	weights="""imagenet"""      ,	input_tensor=lowerCamelCase__      ,	input_shape=lowerCamelCase__      ,	pooling=lowerCamelCase__      ,	classes=1000      ,	classifier_activation="""softmax"""      ,	)

		lowerCAmelCase__   = original_model.trainable_variables
		lowerCAmelCase__   = original_model.non_trainable_variables
		lowerCAmelCase__   = {param.name: param.numpy() for param in tf_params}
		for param in tf_non_train_params:
				lowerCAmelCase__   = param.numpy()
		lowerCAmelCase__   = list(tf_params.keys()  )

		# Load HuggingFace model
		lowerCAmelCase__   = get_efficientnet_config(lowerCamelCase__  )
		lowerCAmelCase__   = EfficientNetForImageClassification(lowerCamelCase__  ).eval()
		lowerCAmelCase__   = hf_model.state_dict()

		# Create src-to-dst parameter name mapping dictionary
		print("""Converting parameters..."""  )
		lowerCAmelCase__   = rename_keys(lowerCamelCase__  )
		replace_params(lowerCamelCase__      ,	lowerCamelCase__      ,	lowerCamelCase__  )

		# Initialize preprocessor and preprocess input image
		lowerCAmelCase__   = convert_image_processor(lowerCamelCase__  )
		lowerCAmelCase__   = preprocessor(images=prepare_img()      ,	return_tensors="""pt"""  )

		# HF model inference
		hf_model.eval()
		with torch.no_grad():
				lowerCAmelCase__   = hf_model(**lowerCamelCase__  )
		lowerCAmelCase__   = outputs.logits.detach().numpy()

		# Original model inference
		lowerCAmelCase__   = False
		lowerCAmelCase__   = CONFIG_MAP[model_name]["""image_size"""]
		lowerCAmelCase__   = prepare_img().resize((image_size, image_size)      ,	resample=PIL.Image.NEAREST  )
		lowerCAmelCase__   = image.img_to_array(lowerCamelCase__  )
		lowerCAmelCase__   = np.expand_dims(lowerCamelCase__      ,	axis=0  )
		lowerCAmelCase__   = original_model.predict(lowerCamelCase__  )

		# Check whether original and HF model outputs match  -> np.allclose
		assert np.allclose(lowerCamelCase__      ,	lowerCamelCase__      ,	atol=1e-3  ), "The predicted logits are not the same."
		print("""Model outputs match!"""  )

		if save_model:
				# Create folder to save model
				if not os.path.isdir(lowerCamelCase__  ):
						os.mkdir(lowerCamelCase__  )
				# Save converted model and image processor
				hf_model.save_pretrained(lowerCamelCase__  )
				preprocessor.save_pretrained(lowerCamelCase__  )

		if push_to_hub:
				# Push model and image processor to hub
				print(f"""Pushing converted {model_name} to the hub..."""  )
				lowerCAmelCase__   = f"""efficientnet-{model_name}"""
				preprocessor.push_to_hub(lowerCamelCase__  )
				hf_model.push_to_hub(lowerCamelCase__  )


if __name__ == "__main__":
			__lowerCAmelCase     :				str    				=    argparse.ArgumentParser()
			# Required parameters
			parser.add_argument(
			    "--model_name",
			    default="b0",
			    type=str,
			    help="Version name of the EfficientNet model you want to convert, select from [b0, b1, b2, b3, b4, b5, b6, b7].",
			)
			parser.add_argument(
			    "--pytorch_dump_folder_path",
			    default="hf_model",
			    type=str,
			    help="Path to the output PyTorch model directory.",
			)
			parser.add_argument("--save_model", action="store_true", help="Save model to local")
			parser.add_argument("--push_to_hub", action="store_true", help="Push model and image processor to the hub")

			__lowerCAmelCase     :				str    				=    parser.parse_args()
			convert_efficientnet_checkpoint(args.model_name, args.pytorch_dump_folder_path, args.save_model, args.push_to_hub)





"""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


__lowerCAmelCase     :				Dict    				=    "CompVis/stable-diffusion-v1-1"
__lowerCAmelCase     :				int    				=    "CompVis/stable-diffusion-v1-2"
__lowerCAmelCase     :				int    				=    "CompVis/stable-diffusion-v1-3"
__lowerCAmelCase     :				Union[str, Any]    				=    "CompVis/stable-diffusion-v1-4"

class    a_   (  __UpperCamelCase      ):




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

							lowerCAmelCase__   = StableDiffusionPipeline.from_pretrained(snake_case__  )
							lowerCAmelCase__   = StableDiffusionPipeline.from_pretrained(snake_case__  )
							lowerCAmelCase__   = StableDiffusionPipeline.from_pretrained(snake_case__  )
							lowerCAmelCase__   = StableDiffusionPipeline(
							    vae=snake_case__	,    text_encoder=snake_case__	,    tokenizer=snake_case__	,    unet=snake_case__	,    scheduler=snake_case__	,    safety_checker=snake_case__	,    feature_extractor=snake_case__	,    requires_safety_checker=snake_case__	,    )

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




					@property
					def     _SCREAMING_SNAKE_CASE    (						self    :  Tuple  ):
							return {k: getattr(self	,    snake_case__  ) for k in self.config.keys() if not k.startswith("""_"""  )}




					def     _SCREAMING_SNAKE_CASE    (						self    :  List[Any]	,    snake_case__    :  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__   = self.unet.config.attention_head_dim // 2
							self.unet.set_attention_slice(snake_case__  )




					def     _SCREAMING_SNAKE_CASE    (						self    :  int  ):
							self.enable_attention_slicing(snake_case__  )




					@torch.no_grad()
					def     _SCREAMING_SNAKE_CASE    (						self    :  int	,    snake_case__    :  Union[str, List[str]]	,    snake_case__    :  int = 512	,    snake_case__    :  int = 512	,    snake_case__    :  int = 50	,    snake_case__    :  float = 7.5	,    snake_case__    :  Optional[Union[str, List[str]]] = None	,    snake_case__    :  Optional[int] = 1	,    snake_case__    :  float = 0.0	,    snake_case__    :  Optional[torch.Generator] = None	,    snake_case__    :  Optional[torch.FloatTensor] = None	,    snake_case__    :  Optional[str] = "pil"	,    snake_case__    :  bool = True	,    snake_case__    :  Optional[Callable[[int, int, torch.FloatTensor], None]] = None	,    snake_case__    :  int = 1	,    **snake_case__    :  List[Any]	,    ):
							return self.pipea(
							    prompt=snake_case__	,    height=snake_case__	,    width=snake_case__	,    num_inference_steps=snake_case__	,    guidance_scale=snake_case__	,    negative_prompt=snake_case__	,    num_images_per_prompt=snake_case__	,    eta=snake_case__	,    generator=snake_case__	,    latents=snake_case__	,    output_type=snake_case__	,    return_dict=snake_case__	,    callback=snake_case__	,    callback_steps=snake_case__	,    **snake_case__	,    )




					@torch.no_grad()
					def     _SCREAMING_SNAKE_CASE    (						self    :  Tuple	,    snake_case__    :  Union[str, List[str]]	,    snake_case__    :  int = 512	,    snake_case__    :  int = 512	,    snake_case__    :  int = 50	,    snake_case__    :  float = 7.5	,    snake_case__    :  Optional[Union[str, List[str]]] = None	,    snake_case__    :  Optional[int] = 1	,    snake_case__    :  float = 0.0	,    snake_case__    :  Optional[torch.Generator] = None	,    snake_case__    :  Optional[torch.FloatTensor] = None	,    snake_case__    :  Optional[str] = "pil"	,    snake_case__    :  bool = True	,    snake_case__    :  Optional[Callable[[int, int, torch.FloatTensor], None]] = None	,    snake_case__    :  int = 1	,    **snake_case__    :  Tuple	,    ):
							return self.pipea(
							    prompt=snake_case__	,    height=snake_case__	,    width=snake_case__	,    num_inference_steps=snake_case__	,    guidance_scale=snake_case__	,    negative_prompt=snake_case__	,    num_images_per_prompt=snake_case__	,    eta=snake_case__	,    generator=snake_case__	,    latents=snake_case__	,    output_type=snake_case__	,    return_dict=snake_case__	,    callback=snake_case__	,    callback_steps=snake_case__	,    **snake_case__	,    )




					@torch.no_grad()
					def     _SCREAMING_SNAKE_CASE    (						self    :  Optional[int]	,    snake_case__    :  Union[str, List[str]]	,    snake_case__    :  int = 512	,    snake_case__    :  int = 512	,    snake_case__    :  int = 50	,    snake_case__    :  float = 7.5	,    snake_case__    :  Optional[Union[str, List[str]]] = None	,    snake_case__    :  Optional[int] = 1	,    snake_case__    :  float = 0.0	,    snake_case__    :  Optional[torch.Generator] = None	,    snake_case__    :  Optional[torch.FloatTensor] = None	,    snake_case__    :  Optional[str] = "pil"	,    snake_case__    :  bool = True	,    snake_case__    :  Optional[Callable[[int, int, torch.FloatTensor], None]] = None	,    snake_case__    :  int = 1	,    **snake_case__    :  Optional[Any]	,    ):
							return self.pipea(
							    prompt=snake_case__	,    height=snake_case__	,    width=snake_case__	,    num_inference_steps=snake_case__	,    guidance_scale=snake_case__	,    negative_prompt=snake_case__	,    num_images_per_prompt=snake_case__	,    eta=snake_case__	,    generator=snake_case__	,    latents=snake_case__	,    output_type=snake_case__	,    return_dict=snake_case__	,    callback=snake_case__	,    callback_steps=snake_case__	,    **snake_case__	,    )




					@torch.no_grad()
					def     _SCREAMING_SNAKE_CASE    (						self    :  List[str]	,    snake_case__    :  Union[str, List[str]]	,    snake_case__    :  int = 512	,    snake_case__    :  int = 512	,    snake_case__    :  int = 50	,    snake_case__    :  float = 7.5	,    snake_case__    :  Optional[Union[str, List[str]]] = None	,    snake_case__    :  Optional[int] = 1	,    snake_case__    :  float = 0.0	,    snake_case__    :  Optional[torch.Generator] = None	,    snake_case__    :  Optional[torch.FloatTensor] = None	,    snake_case__    :  Optional[str] = "pil"	,    snake_case__    :  bool = True	,    snake_case__    :  Optional[Callable[[int, int, torch.FloatTensor], None]] = None	,    snake_case__    :  int = 1	,    **snake_case__    :  str	,    ):
							return self.pipea(
							    prompt=snake_case__	,    height=snake_case__	,    width=snake_case__	,    num_inference_steps=snake_case__	,    guidance_scale=snake_case__	,    negative_prompt=snake_case__	,    num_images_per_prompt=snake_case__	,    eta=snake_case__	,    generator=snake_case__	,    latents=snake_case__	,    output_type=snake_case__	,    return_dict=snake_case__	,    callback=snake_case__	,    callback_steps=snake_case__	,    **snake_case__	,    )




					@torch.no_grad()
					def     _SCREAMING_SNAKE_CASE    (						self    :  Union[str, Any]	,    snake_case__    :  Union[str, List[str]]	,    snake_case__    :  int = 512	,    snake_case__    :  int = 512	,    snake_case__    :  int = 50	,    snake_case__    :  float = 7.5	,    snake_case__    :  Optional[Union[str, List[str]]] = None	,    snake_case__    :  Optional[int] = 1	,    snake_case__    :  float = 0.0	,    snake_case__    :  Optional[torch.Generator] = None	,    snake_case__    :  Optional[torch.FloatTensor] = None	,    snake_case__    :  Optional[str] = "pil"	,    snake_case__    :  bool = True	,    snake_case__    :  Optional[Callable[[int, int, torch.FloatTensor], None]] = None	,    snake_case__    :  int = 1	,    **snake_case__    :  Optional[Any]	,    ):
							lowerCAmelCase__   = """cuda""" if torch.cuda.is_available() else """cpu"""
							self.to(snake_case__  )

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

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

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

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

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




