


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


UpperCamelCase						:				List[str]             =      "CompVis/stable-diffusion-v1-1"
UpperCamelCase						:				List[Any]             =      "CompVis/stable-diffusion-v1-2"
UpperCamelCase						:				str             =      "CompVis/stable-diffusion-v1-3"
UpperCamelCase						:				str             =      "CompVis/stable-diffusion-v1-4"



class 			lowerCamelCase__						(   __lowercase			):







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

								A					       = StableDiffusionPipeline.from_pretrained(_A		)
								A					       = StableDiffusionPipeline.from_pretrained(_A		)
								A					       = StableDiffusionPipeline.from_pretrained(_A		)
								A					       = 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   :    Optional[Any]		):
								return {k: getattr(self			,			_A		) for k in self.config.keys() if not k.startswith('_'		)}







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







						def __a						(							self   :    Any		):
								self.enable_attention_slicing(_A		)







						@torch.no_grad()
						def __a						(							self   :    Optional[Any]			,			_lowercase   :    Union[str, List[str]]			,			_lowercase   :    int = 512			,			_lowercase   :    int = 512			,			_lowercase   :    int = 50			,			_lowercase   :    float = 7.5			,			_lowercase   :    Optional[Union[str, List[str]]] = None			,			_lowercase   :    Optional[int] = 1			,			_lowercase   :    float = 0.0			,			_lowercase   :    Optional[torch.Generator] = None			,			_lowercase   :    Optional[torch.FloatTensor] = None			,			_lowercase   :    Optional[str] = "pil"			,			_lowercase   :    bool = True			,			_lowercase   :    Optional[Callable[[int, int, torch.FloatTensor], None]] = None			,			_lowercase   :    int = 1			,			**_lowercase   :    Dict			,			):
								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			,			_lowercase   :    Union[str, List[str]]			,			_lowercase   :    int = 512			,			_lowercase   :    int = 512			,			_lowercase   :    int = 50			,			_lowercase   :    float = 7.5			,			_lowercase   :    Optional[Union[str, List[str]]] = None			,			_lowercase   :    Optional[int] = 1			,			_lowercase   :    float = 0.0			,			_lowercase   :    Optional[torch.Generator] = None			,			_lowercase   :    Optional[torch.FloatTensor] = None			,			_lowercase   :    Optional[str] = "pil"			,			_lowercase   :    bool = True			,			_lowercase   :    Optional[Callable[[int, int, torch.FloatTensor], None]] = None			,			_lowercase   :    int = 1			,			**_lowercase   :    Optional[Any]			,			):
								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[str]			,			_lowercase   :    Union[str, List[str]]			,			_lowercase   :    int = 512			,			_lowercase   :    int = 512			,			_lowercase   :    int = 50			,			_lowercase   :    float = 7.5			,			_lowercase   :    Optional[Union[str, List[str]]] = None			,			_lowercase   :    Optional[int] = 1			,			_lowercase   :    float = 0.0			,			_lowercase   :    Optional[torch.Generator] = None			,			_lowercase   :    Optional[torch.FloatTensor] = None			,			_lowercase   :    Optional[str] = "pil"			,			_lowercase   :    bool = True			,			_lowercase   :    Optional[Callable[[int, int, torch.FloatTensor], None]] = None			,			_lowercase   :    int = 1			,			**_lowercase   :    List[Any]			,			):
								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   :    Dict			,			_lowercase   :    Union[str, List[str]]			,			_lowercase   :    int = 512			,			_lowercase   :    int = 512			,			_lowercase   :    int = 50			,			_lowercase   :    float = 7.5			,			_lowercase   :    Optional[Union[str, List[str]]] = None			,			_lowercase   :    Optional[int] = 1			,			_lowercase   :    float = 0.0			,			_lowercase   :    Optional[torch.Generator] = None			,			_lowercase   :    Optional[torch.FloatTensor] = None			,			_lowercase   :    Optional[str] = "pil"			,			_lowercase   :    bool = True			,			_lowercase   :    Optional[Callable[[int, int, torch.FloatTensor], None]] = None			,			_lowercase   :    int = 1			,			**_lowercase   :    Optional[int]			,			):
								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   :    Dict			,			_lowercase   :    Union[str, List[str]]			,			_lowercase   :    int = 512			,			_lowercase   :    int = 512			,			_lowercase   :    int = 50			,			_lowercase   :    float = 7.5			,			_lowercase   :    Optional[Union[str, List[str]]] = None			,			_lowercase   :    Optional[int] = 1			,			_lowercase   :    float = 0.0			,			_lowercase   :    Optional[torch.Generator] = None			,			_lowercase   :    Optional[torch.FloatTensor] = None			,			_lowercase   :    Optional[str] = "pil"			,			_lowercase   :    bool = True			,			_lowercase   :    Optional[Callable[[int, int, torch.FloatTensor], None]] = None			,			_lowercase   :    int = 1			,			**_lowercase   :    List[Any]			,			):
								A					       = '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
								A					       = 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
								A					       = 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
								A					       = 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
								A					       = 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"""


def  __snake_case       (   UpperCamelCase__ ,			UpperCamelCase__ = " "	)      ->		list:







		"""simple docstring"""





		A					       = []

		A					       = 0
		for index, char in enumerate(UpperCamelCase__	):
				if char == separator:
						split_words.append(string[last_index:index]	)
						A					       = index + 1
				elif index + 1 == len(UpperCamelCase__	):
						split_words.append(string[last_index : index + 1]	)
		return split_words


if __name__ == "__main__":
	from doctest import testmod

	testmod()





