

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







class 							A__   (	A__  ):





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





							'''simple docstring'''






							super()._init_()

							_SCREAMING_SNAKE_CASE							   =StableDiffusionPipeline.from_pretrained(__A			)
							_SCREAMING_SNAKE_CASE							   =StableDiffusionPipeline.from_pretrained(__A			)
							_SCREAMING_SNAKE_CASE							   =StableDiffusionPipeline.from_pretrained(__A			)
							_SCREAMING_SNAKE_CASE							   =StableDiffusionPipeline(
							    vae=__A							, text_encoder=__A							, tokenizer=__A							, unet=__A							, scheduler=__A							, safety_checker=__A							, feature_extractor=__A							, requires_safety_checker=__A							, )

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





		@property
		def 						A  (		self				:     List[str]			)     ->   Dict[str, Any]:





							'''simple docstring'''






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





		def 						A  (		self				:     Optional[int]							, _a				:     Optional[Union[str, int]] = "auto"			)     ->   str:





							'''simple docstring'''






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





		def 						A  (		self				:     Optional[Any]			)     ->   Dict:





							'''simple docstring'''






							self.enable_attention_slicing(__A			)





		@torch.no_grad()
		def 						A  (		self				:     Optional[int]							, _a				:     Union[str, List[str]]							, _a				:     int = 512							, _a				:     int = 512							, _a				:     int = 50							, _a				:     float = 7.5							, _a				:     Optional[Union[str, List[str]]] = None							, _a				:     Optional[int] = 1							, _a				:     float = 0.0							, _a				:     Optional[torch.Generator] = None							, _a				:     Optional[torch.FloatTensor] = None							, _a				:     Optional[str] = "pil"							, _a				:     bool = True							, _a				:     Optional[Callable[[int, int, torch.FloatTensor], None]] = None							, _a				:     int = 1							, **_a				:     Tuple							, )     ->   str:





							'''simple docstring'''






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





		@torch.no_grad()
		def 						A  (		self				:     Union[str, Any]							, _a				:     Union[str, List[str]]							, _a				:     int = 512							, _a				:     int = 512							, _a				:     int = 50							, _a				:     float = 7.5							, _a				:     Optional[Union[str, List[str]]] = None							, _a				:     Optional[int] = 1							, _a				:     float = 0.0							, _a				:     Optional[torch.Generator] = None							, _a				:     Optional[torch.FloatTensor] = None							, _a				:     Optional[str] = "pil"							, _a				:     bool = True							, _a				:     Optional[Callable[[int, int, torch.FloatTensor], None]] = None							, _a				:     int = 1							, **_a				:     Any							, )     ->   Dict:





							'''simple docstring'''






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





		@torch.no_grad()
		def 						A  (		self				:     Any							, _a				:     Union[str, List[str]]							, _a				:     int = 512							, _a				:     int = 512							, _a				:     int = 50							, _a				:     float = 7.5							, _a				:     Optional[Union[str, List[str]]] = None							, _a				:     Optional[int] = 1							, _a				:     float = 0.0							, _a				:     Optional[torch.Generator] = None							, _a				:     Optional[torch.FloatTensor] = None							, _a				:     Optional[str] = "pil"							, _a				:     bool = True							, _a				:     Optional[Callable[[int, int, torch.FloatTensor], None]] = None							, _a				:     int = 1							, **_a				:     Optional[Any]							, )     ->   Dict:





							'''simple docstring'''






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





		@torch.no_grad()
		def 						A  (		self				:     List[Any]							, _a				:     Union[str, List[str]]							, _a				:     int = 512							, _a				:     int = 512							, _a				:     int = 50							, _a				:     float = 7.5							, _a				:     Optional[Union[str, List[str]]] = None							, _a				:     Optional[int] = 1							, _a				:     float = 0.0							, _a				:     Optional[torch.Generator] = None							, _a				:     Optional[torch.FloatTensor] = None							, _a				:     Optional[str] = "pil"							, _a				:     bool = True							, _a				:     Optional[Callable[[int, int, torch.FloatTensor], None]] = None							, _a				:     int = 1							, **_a				:     List[Any]							, )     ->   Optional[int]:





							'''simple docstring'''






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





		@torch.no_grad()
		def 						A  (		self				:     int							, _a				:     Union[str, List[str]]							, _a				:     int = 512							, _a				:     int = 512							, _a				:     int = 50							, _a				:     float = 7.5							, _a				:     Optional[Union[str, List[str]]] = None							, _a				:     Optional[int] = 1							, _a				:     float = 0.0							, _a				:     Optional[torch.Generator] = None							, _a				:     Optional[torch.FloatTensor] = None							, _a				:     Optional[str] = "pil"							, _a				:     bool = True							, _a				:     Optional[Callable[[int, int, torch.FloatTensor], None]] = None							, _a				:     int = 1							, **_a				:     List[Any]							, )     ->   Union[str, Any]:





							'''simple docstring'''






							_SCREAMING_SNAKE_CASE							   ='cuda' if torch.cuda.is_available() else 'cpu'
							self.to(__A			)

							# Checks if the height and width are divisible by 8 or not
							if height % 8 != 0 or width % 8 != 0:
												raise ValueError(f"`height` and `width` must be divisible by 8 but are {height} and {width}."			)

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

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

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

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

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



'''simple docstring'''
from ...utils import logging
from ..ta.modeling_tf_ta import TFTaEncoderModel, TFTaForConditionalGeneration, TFTaModel
from .configuration_mta import MTaConfig


lowerCamelCase			:				Optional[Any] 			=					logging.get_logger(__name__)

lowerCamelCase			:				Optional[Any] 			=					"T5Config"







class 							A__   (	A__  ):
  A__					=    'mt5'
  A__					=    MTaConfig







class 							A__   (	A__  ):
  A__					=    'mt5'
  A__					=    MTaConfig







class 							A__   (	A__  ):
  A__					=    'mt5'
  A__					=    MTaConfig
