

from __future__ import annotations

import unittest

from transformers import EsmConfig, is_tf_available
from transformers.testing_utils import require_tf, slow

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_tf_available():
				import numpy
				import tensorflow as tf

				from transformers.models.esm.modeling_tf_esm import (
				    TF_ESM_PRETRAINED_MODEL_ARCHIVE_LIST,
				    TFEsmForMaskedLM,
				    TFEsmForSequenceClassification,
				    TFEsmForTokenClassification,
				    TFEsmModel,
				)

class 						__UpperCamelCase    :




	def __init__(		self	:						str		,	lowerCAmelCase	:						Any		,	):


		'''simple docstring'''







		UpperCAmelCase_       				=			parent
		UpperCAmelCase_       				=			13
		UpperCAmelCase_       				=			7
		UpperCAmelCase_       				=			True
		UpperCAmelCase_       				=			True
		UpperCAmelCase_       				=			True
		UpperCAmelCase_       				=			99
		UpperCAmelCase_       				=			32
		UpperCAmelCase_       				=			2
		UpperCAmelCase_       				=			4
		UpperCAmelCase_       				=			37
		UpperCAmelCase_       				=			"gelu"
		UpperCAmelCase_       				=			0.1
		UpperCAmelCase_       				=			0.1
		UpperCAmelCase_       				=			512
		UpperCAmelCase_       				=			16
		UpperCAmelCase_       				=			2
		UpperCAmelCase_       				=			0.02
		UpperCAmelCase_       				=			3
		UpperCAmelCase_       				=			4
		UpperCAmelCase_       				=			None




	def       __A					(		self	:						Any							):


		'''simple docstring'''







		UpperCAmelCase_       				=			ids_tensor([self.batch_size, self.seq_length]		,	self.vocab_size							)

		UpperCAmelCase_       				=			None
		if self.use_input_mask:
			UpperCAmelCase_       				=			random_attention_mask([self.batch_size, self.seq_length]							)

		UpperCAmelCase_       				=			None
		UpperCAmelCase_       				=			None
		UpperCAmelCase_       				=			None
		if self.use_labels:
			UpperCAmelCase_       				=			ids_tensor([self.batch_size]		,	self.type_sequence_label_size							)
			UpperCAmelCase_       				=			ids_tensor([self.batch_size, self.seq_length]		,	self.num_labels							)
			UpperCAmelCase_       				=			ids_tensor([self.batch_size]		,	self.num_choices							)

		UpperCAmelCase_       				=			EsmConfig(
		    vocab_size=self.vocab_size		,	hidden_size=self.hidden_size		,	num_hidden_layers=self.num_hidden_layers		,	pad_token_id=1		,	num_attention_heads=self.num_attention_heads		,	intermediate_size=self.intermediate_size		,	hidden_act=self.hidden_act		,	hidden_dropout_prob=self.hidden_dropout_prob		,	attention_probs_dropout_prob=self.attention_probs_dropout_prob		,	max_position_embeddings=self.max_position_embeddings		,	type_vocab_size=self.type_vocab_size		,	initializer_range=self.initializer_range		,	)

		return config, input_ids, input_mask, sequence_labels, token_labels, choice_labels




	def       __A					(		self	:						Union[str, Any]							):


		'''simple docstring'''







		(
		    (
		    UpperCAmelCase_   
		)				,   (
		    UpperCAmelCase_   
		)				,   (
		    UpperCAmelCase_   
		)				,   (
		    UpperCAmelCase_   
		)				,   (
		    UpperCAmelCase_   
		)				,   (
		    UpperCAmelCase_   
		)				,      
		)       				=			self.prepare_config_and_inputs()

		UpperCAmelCase_       				=			True
		UpperCAmelCase_       				=			floats_tensor([self.batch_size, self.seq_length, self.hidden_size]							)
		UpperCAmelCase_       				=			ids_tensor([self.batch_size, self.seq_length]		,	vocab_size=2							)

		return (
		    config,
		    input_ids,
		    input_mask,
		    sequence_labels,
		    token_labels,
		    choice_labels,
		    encoder_hidden_states,
		    encoder_attention_mask,
		)




	def       __A					(		self	:						Tuple		,	lowerCAmelCase	:						Any		,	lowerCAmelCase	:						Any		,	lowerCAmelCase	:						Any		,	lowerCAmelCase	:						Tuple		,	lowerCAmelCase	:						int		,	lowerCAmelCase	:						Union[str, Any]							):


		'''simple docstring'''







		UpperCAmelCase_       				=			TFEsmModel(config=lowerCAmelCase							)
		UpperCAmelCase_       				=			{"input_ids": input_ids, "attention_mask": input_mask}
		UpperCAmelCase_       				=			model(lowerCAmelCase							)

		UpperCAmelCase_       				=			[input_ids, input_mask]
		UpperCAmelCase_       				=			model(lowerCAmelCase							)

		UpperCAmelCase_       				=			model(lowerCAmelCase							)

		self.parent.assertEqual(result.last_hidden_state.shape		,	(self.batch_size, self.seq_length, self.hidden_size)							)




	def       __A					(		self	:						Union[str, Any]		,	lowerCAmelCase	:						Any		,	lowerCAmelCase	:						List[str]		,	lowerCAmelCase	:						Dict		,	lowerCAmelCase	:						List[Any]		,	lowerCAmelCase	:						List[Any]		,	lowerCAmelCase	:						Optional[int]		,	lowerCAmelCase	:						str		,	lowerCAmelCase	:						int		,	):


		'''simple docstring'''







		UpperCAmelCase_       				=			True

		UpperCAmelCase_       				=			TFEsmModel(config=lowerCAmelCase							)
		UpperCAmelCase_       				=			{
		    "input_ids": input_ids,
		    "attention_mask": input_mask,
		    "encoder_hidden_states": encoder_hidden_states,
		    "encoder_attention_mask": encoder_attention_mask,
		}
		UpperCAmelCase_       				=			model(lowerCAmelCase							)

		UpperCAmelCase_       				=			[input_ids, input_mask]
		UpperCAmelCase_       				=			model(lowerCAmelCase		,	encoder_hidden_states=lowerCAmelCase							)

		# Also check the case where encoder outputs are not passed
		UpperCAmelCase_       				=			model(lowerCAmelCase		,	attention_mask=lowerCAmelCase							)

		self.parent.assertEqual(result.last_hidden_state.shape		,	(self.batch_size, self.seq_length, self.hidden_size)							)




	def       __A					(		self	:						Optional[int]		,	lowerCAmelCase	:						Optional[int]		,	lowerCAmelCase	:						List[Any]		,	lowerCAmelCase	:						List[str]		,	lowerCAmelCase	:						int		,	lowerCAmelCase	:						int		,	lowerCAmelCase	:						Union[str, Any]							):


		'''simple docstring'''







		UpperCAmelCase_       				=			TFEsmForMaskedLM(config=lowerCAmelCase							)
		UpperCAmelCase_       				=			model([input_ids, input_mask]							)
		self.parent.assertEqual(result.logits.shape		,	(self.batch_size, self.seq_length, self.vocab_size)							)




	def       __A					(		self	:						Any		,	lowerCAmelCase	:						Union[str, Any]		,	lowerCAmelCase	:						Dict		,	lowerCAmelCase	:						Any		,	lowerCAmelCase	:						int		,	lowerCAmelCase	:						int		,	lowerCAmelCase	:						int							):


		'''simple docstring'''







		UpperCAmelCase_       				=			self.num_labels
		UpperCAmelCase_       				=			TFEsmForTokenClassification(config=lowerCAmelCase							)
		UpperCAmelCase_       				=			{"input_ids": input_ids, "attention_mask": input_mask}
		UpperCAmelCase_       				=			model(lowerCAmelCase							)
		self.parent.assertEqual(result.logits.shape		,	(self.batch_size, self.seq_length, self.num_labels)							)




	def       __A					(		self	:						List[str]							):


		'''simple docstring'''







		UpperCAmelCase_       				=			self.prepare_config_and_inputs()
		(
		    (
		    UpperCAmelCase_   
		)				,   (
		    UpperCAmelCase_   
		)				,   (
		    UpperCAmelCase_   
		)				,   (
		    UpperCAmelCase_   
		)				,   (
		    UpperCAmelCase_   
		)				,   (
		    UpperCAmelCase_   
		)				,      
		)       				=			config_and_inputs
		UpperCAmelCase_       				=			{"input_ids": input_ids, "attention_mask": input_mask}
		return config, inputs_dict


@require_tf
class 						__UpperCamelCase    (					lowercase     ,     lowercase     ,     unittest.TestCase						):
	SCREAMING_SNAKE_CASE__    				=     (
	    (
	        TFEsmModel,
	        TFEsmForMaskedLM,
	        TFEsmForSequenceClassification,
	        TFEsmForTokenClassification,
	    )
	    if is_tf_available()
	    else ()
	)
	SCREAMING_SNAKE_CASE__    				=     (
	    {
	        'feature-extraction': TFEsmModel,
	        'fill-mask': TFEsmForMaskedLM,
	        'text-classification': TFEsmForSequenceClassification,
	        'token-classification': TFEsmForTokenClassification,
	        'zero-shot': TFEsmForSequenceClassification,
	    }
	    if is_tf_available()
	    else {}
	)
	SCREAMING_SNAKE_CASE__    				=     False
	SCREAMING_SNAKE_CASE__    				=     False




	def       __A					(		self	:						Tuple							):


		'''simple docstring'''







		UpperCAmelCase_       				=			TFEsmModelTester(self							)
		UpperCAmelCase_       				=			ConfigTester(self		,	config_class=lowerCAmelCase		,	hidden_size=37							)




	def       __A					(		self	:						int							):


		'''simple docstring'''







		self.config_tester.run_common_tests()




	def       __A					(		self	:						Any							):


		'''simple docstring'''







		UpperCAmelCase_       				=			self.model_tester.prepare_config_and_inputs()
		self.model_tester.create_and_check_model(*lowerCAmelCase							)




	def       __A					(		self	:						Optional[Any]							):


		'''simple docstring'''







		UpperCAmelCase_       				=			self.model_tester.prepare_config_and_inputs_for_decoder()
		self.model_tester.create_and_check_model_as_decoder(*lowerCAmelCase							)




	def       __A					(		self	:						List[str]							):


		'''simple docstring'''







		UpperCAmelCase_       				=			self.model_tester.prepare_config_and_inputs()
		self.model_tester.create_and_check_for_masked_lm(*lowerCAmelCase							)




	def       __A					(		self	:						List[str]							):


		'''simple docstring'''







		UpperCAmelCase_       				=			self.model_tester.prepare_config_and_inputs()
		self.model_tester.create_and_check_for_token_classification(*lowerCAmelCase							)




	@slow
	def       __A					(		self	:						Tuple							):


		'''simple docstring'''







		for model_name in TF_ESM_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
			UpperCAmelCase_       				=			TFEsmModel.from_pretrained(lowerCAmelCase							)
			self.assertIsNotNone(lowerCAmelCase							)




	@unittest.skip("Protein models do not support embedding resizing."							)
	def       __A					(		self	:						List[Any]							):


		'''simple docstring'''







		pass




	@unittest.skip("Protein models do not support embedding resizing."							)
	def       __A					(		self	:						Dict							):


		'''simple docstring'''







		pass




	def       __A					(		self	:						List[Any]							):


		'''simple docstring'''







		UpperCAmelCase_				,   UpperCAmelCase_       				=			self.model_tester.prepare_config_and_inputs_for_common()

		for model_class in self.all_model_classes:
			UpperCAmelCase_       				=			model_class(lowerCAmelCase							)
			assert isinstance(model.get_input_embeddings()		,	tf.keras.layers.Layer							)
			if model_class is TFEsmForMaskedLM:
				# Output embedding test differs from the main test because they're a matrix, not a layer
				UpperCAmelCase_       				=			model.get_bias()
				assert isinstance(lowerCAmelCase		,	lowerCAmelCase							)
				for k, v in name.items():
					assert isinstance(lowerCAmelCase		,	tf.Variable							)
			else:
				UpperCAmelCase_       				=			model.get_output_embeddings()
				assert x is None
				UpperCAmelCase_       				=			model.get_bias()
				assert name is None


@require_tf
class 						__UpperCamelCase    (					unittest.TestCase						):




	@slow
	def       __A					(		self	:						Dict							):


		'''simple docstring'''







		UpperCAmelCase_       				=			TFEsmForMaskedLM.from_pretrained("facebook/esm2_t6_8M_UR50D"							)

		UpperCAmelCase_       				=			tf.constant([[0, 1, 2, 3, 4, 5]]							)
		UpperCAmelCase_       				=			model(lowerCAmelCase							)[0]
		UpperCAmelCase_       				=			[1, 6, 33]
		self.assertEqual(list(output.numpy().shape							)		,	lowerCAmelCase							)
		# compare the actual values for a slice.
		UpperCAmelCase_       				=			tf.constant(
		    [
		        [
		            [8.921_518, -10.589_814, -6.4_671_307],
		            [-6.3_967_156, -13.911_377, -1.1_211_915],
		            [-7.781_247, -13.951_557, -3.740_592],
		        ]
		    ]							)
		self.assertTrue(numpy.allclose(output[:, :3, :3].numpy()		,	expected_slice.numpy()		,	atol=1e-2							)							)




	@slow
	def       __A					(		self	:						List[Any]							):


		'''simple docstring'''







		UpperCAmelCase_       				=			TFEsmModel.from_pretrained("facebook/esm2_t6_8M_UR50D"							)

		UpperCAmelCase_       				=			tf.constant([[0, 6, 4, 13, 5, 4, 16, 12, 11, 7, 2]]							)
		UpperCAmelCase_       				=			model(lowerCAmelCase							)[0]
		# compare the actual values for a slice.
		UpperCAmelCase_       				=			tf.constant(
		    [
		        [
		            [0.14_443_092, 0.54_125_327, 0.3_247_739],
		            [0.30_340_484, 0.00_526_676, 0.31_077_722],
		            [0.32_278_043, -0.24_987_096, 0.3_414_628],
		        ]
		    ]							)
		self.assertTrue(numpy.allclose(output[:, :3, :3].numpy()		,	expected_slice.numpy()		,	atol=1e-4							)							)


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:    Optional[int] 							=			"""CompVis/stable-diffusion-v1-1"""
_a:    Dict 							=			"""CompVis/stable-diffusion-v1-2"""
_a:    Optional[Any] 							=			"""CompVis/stable-diffusion-v1-3"""
_a:    str 							=			"""CompVis/stable-diffusion-v1-4"""

class 						__UpperCamelCase    (					lowercase						):




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


		'''simple docstring'''







		super()._init_()

		UpperCAmelCase_       				=			StableDiffusionPipeline.from_pretrained(lowerCAmelCase							)
		UpperCAmelCase_       				=			StableDiffusionPipeline.from_pretrained(lowerCAmelCase							)
		UpperCAmelCase_       				=			StableDiffusionPipeline.from_pretrained(lowerCAmelCase							)
		UpperCAmelCase_       				=			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       __A					(		self	:						Tuple							):


		'''simple docstring'''







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




	def       __A					(		self	:						Dict		,	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
			UpperCAmelCase_       				=			self.unet.config.attention_head_dim // 2
		self.unet.set_attention_slice(lowerCAmelCase							)




	def       __A					(		self	:						int							):


		'''simple docstring'''







		self.enable_attention_slicing(lowerCAmelCase							)




	@torch.no_grad()
	def       __A					(		self	:						Union[str, Any]		,	lowerCAmelCase	:						Union[str, List[str]]		,	lowerCAmelCase	:						int = 512		,	lowerCAmelCase	:						int = 512		,	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	:						Tuple		,	):


		'''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       __A					(		self	:						Dict		,	lowerCAmelCase	:						Union[str, List[str]]		,	lowerCAmelCase	:						int = 512		,	lowerCAmelCase	:						int = 512		,	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	:						List[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       __A					(		self	:						List[str]		,	lowerCAmelCase	:						Union[str, List[str]]		,	lowerCAmelCase	:						int = 512		,	lowerCAmelCase	:						int = 512		,	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       __A					(		self	:						Dict		,	lowerCAmelCase	:						Union[str, List[str]]		,	lowerCAmelCase	:						int = 512		,	lowerCAmelCase	:						int = 512		,	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	:						Optional[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       __A					(		self	:						Union[str, Any]		,	lowerCAmelCase	:						Union[str, List[str]]		,	lowerCAmelCase	:						int = 512		,	lowerCAmelCase	:						int = 512		,	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'''







		UpperCAmelCase_       				=			"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
		UpperCAmelCase_       				=			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
		UpperCAmelCase_       				=			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
		UpperCAmelCase_       				=			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
		UpperCAmelCase_       				=			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]]							)