





'''simple docstring'''




import os
import re
from shutil import copyfile
from typing import Any, Dict, List, Optional, Tuple

import sentencepiece as spm

from ...tokenization_utils import AddedToken, PreTrainedTokenizer
from ...utils import logging


__UpperCAmelCase            =       logging.get_logger(__name__)

__UpperCAmelCase            =       {"""vocab_file""": """spiece.model"""}

__UpperCAmelCase            =       {
    """vocab_file""": {
        """google/bigbird-roberta-base""": """https://huggingface.co/google/bigbird-roberta-base/resolve/main/spiece.model""",
        """google/bigbird-roberta-large""": (
            """https://huggingface.co/google/bigbird-roberta-large/resolve/main/spiece.model"""
        ),
        """google/bigbird-base-trivia-itc""": (
            """https://huggingface.co/google/bigbird-base-trivia-itc/resolve/main/spiece.model"""
        ),
    }
}

__UpperCAmelCase            =       {
    """google/bigbird-roberta-base""": 4096,
    """google/bigbird-roberta-large""": 4096,
    """google/bigbird-base-trivia-itc""": 4096,
}




class      UpperCamelCase__					(					lowercase_			):




					"""simple docstring"""
					SCREAMING_SNAKE_CASE__				=	VOCAB_FILES_NAMES
					SCREAMING_SNAKE_CASE__				=	PRETRAINED_VOCAB_FILES_MAP
					SCREAMING_SNAKE_CASE__				=	PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
					SCREAMING_SNAKE_CASE__				=	['''input_ids''', '''attention_mask''']
					SCREAMING_SNAKE_CASE__				=	[]


					def __init__(						self				:			Optional[int]      ,						lowerCamelCase_				:			List[Any]      ,						lowerCamelCase_				:			str="<unk>"      ,						lowerCamelCase_				:			List[str]="<s>"      ,						lowerCamelCase_				:			List[Any]="</s>"      ,						lowerCamelCase_				:			Optional[Any]="<pad>"      ,						lowerCamelCase_				:			Tuple="[SEP]"      ,						lowerCamelCase_				:			str="[MASK]"      ,						lowerCamelCase_				:			Any="[CLS]"      ,						lowerCamelCase_				:			Optional[Dict[str, Any]] = None      ,						**lowerCamelCase_				:			int      ,						):

							'''simple docstring'''



							SCREAMING_SNAKE_CASE :				str		=			AddedToken(lowerCamelCase_      ,						lstrip=lowerCamelCase_      ,						rstrip=lowerCamelCase_						) if isinstance(lowerCamelCase_      ,						lowerCamelCase_						) else bos_token
							SCREAMING_SNAKE_CASE :				List[str]		=			AddedToken(lowerCamelCase_      ,						lstrip=lowerCamelCase_      ,						rstrip=lowerCamelCase_						) if isinstance(lowerCamelCase_      ,						lowerCamelCase_						) else eos_token
							SCREAMING_SNAKE_CASE :				str		=			AddedToken(lowerCamelCase_      ,						lstrip=lowerCamelCase_      ,						rstrip=lowerCamelCase_						) if isinstance(lowerCamelCase_      ,						lowerCamelCase_						) else unk_token
							SCREAMING_SNAKE_CASE :				Any		=			AddedToken(lowerCamelCase_      ,						lstrip=lowerCamelCase_      ,						rstrip=lowerCamelCase_						) if isinstance(lowerCamelCase_      ,						lowerCamelCase_						) else pad_token
							SCREAMING_SNAKE_CASE :				Union[str, Any]		=			AddedToken(lowerCamelCase_      ,						lstrip=lowerCamelCase_      ,						rstrip=lowerCamelCase_						) if isinstance(lowerCamelCase_      ,						lowerCamelCase_						) else cls_token
							SCREAMING_SNAKE_CASE :				str		=			AddedToken(lowerCamelCase_      ,						lstrip=lowerCamelCase_      ,						rstrip=lowerCamelCase_						) if isinstance(lowerCamelCase_      ,						lowerCamelCase_						) else sep_token

							# Mask token behave like a normal word, i.e. include the space before it
							SCREAMING_SNAKE_CASE :				Optional[int]		=			AddedToken(lowerCamelCase_      ,						lstrip=lowerCamelCase_      ,						rstrip=lowerCamelCase_						) if isinstance(lowerCamelCase_      ,						lowerCamelCase_						) else mask_token

							SCREAMING_SNAKE_CASE :				Tuple		=			{} if sp_model_kwargs is None else sp_model_kwargs

							super().__init__(
							    bos_token=lowerCamelCase_      ,						eos_token=lowerCamelCase_      ,						unk_token=lowerCamelCase_      ,						pad_token=lowerCamelCase_      ,						sep_token=lowerCamelCase_      ,						mask_token=lowerCamelCase_      ,						cls_token=lowerCamelCase_      ,						sp_model_kwargs=self.sp_model_kwargs      ,						**lowerCamelCase_      ,						)

							SCREAMING_SNAKE_CASE :				List[str]		=			vocab_file

							SCREAMING_SNAKE_CASE :				Optional[int]		=			spm.SentencePieceProcessor(**self.sp_model_kwargs						)
							self.sp_model.Load(lowerCamelCase_						)


					@property
					def lowerCamelCase_			(						self				:			Optional[int]						):

							'''simple docstring'''



							return self.sp_model.get_piece_size()


					def lowerCamelCase_			(						self				:			Tuple						):

							'''simple docstring'''



							SCREAMING_SNAKE_CASE :				str		=			{self.convert_ids_to_tokens(lowerCamelCase_						): i for i in range(self.vocab_size						)}
							vocab.update(self.added_tokens_encoder						)
							return vocab


					def __getstate__(						self				:			int						):

							'''simple docstring'''



							SCREAMING_SNAKE_CASE :				int		=			self.__dict__.copy()
							SCREAMING_SNAKE_CASE :				Union[str, Any]		=			None
							return state


					def __setstate__(						self				:			Dict      ,						lowerCamelCase_				:			List[str]						):

							'''simple docstring'''



							SCREAMING_SNAKE_CASE :				Optional[Any]		=			d

							# for backward compatibility
							if not hasattr(self      ,						"""sp_model_kwargs"""						):
									SCREAMING_SNAKE_CASE :				int		=			{}

							SCREAMING_SNAKE_CASE :				List[Any]		=			spm.SentencePieceProcessor(**self.sp_model_kwargs						)
							self.sp_model.Load(self.vocab_file						)


					def lowerCamelCase_			(						self				:			Any      ,						lowerCamelCase_				:			str						):

							'''simple docstring'''



							return self.sp_model.encode(lowerCamelCase_      ,						out_type=lowerCamelCase_						)


					def lowerCamelCase_			(						self				:			List[Any]      ,						lowerCamelCase_				:			int						):

							'''simple docstring'''



							return self.sp_model.piece_to_id(lowerCamelCase_						)


					def lowerCamelCase_			(						self				:			Any      ,						lowerCamelCase_				:			Optional[int]						):

							'''simple docstring'''



							SCREAMING_SNAKE_CASE :				Union[str, Any]		=			self.sp_model.IdToPiece(lowerCamelCase_						)
							return token


					def lowerCamelCase_			(						self				:			Any      ,						lowerCamelCase_				:			int						):

							'''simple docstring'''



							SCREAMING_SNAKE_CASE :				int		=			[]
							SCREAMING_SNAKE_CASE :				int		=			""""""
							SCREAMING_SNAKE_CASE :				Dict		=			False
							for token in tokens:
									# make sure that special tokens are not decoded using sentencepiece model
									if token in self.all_special_tokens:
											if not prev_is_special:
													out_string += " "
											out_string += self.sp_model.decode(lowerCamelCase_						) + token
											SCREAMING_SNAKE_CASE :				int		=			True
											SCREAMING_SNAKE_CASE :				List[str]		=			[]
									else:
											current_sub_tokens.append(lowerCamelCase_						)
											SCREAMING_SNAKE_CASE :				str		=			False
							out_string += self.sp_model.decode(lowerCamelCase_						)
							return out_string.strip()


					def lowerCamelCase_			(						self				:			List[str]      ,						lowerCamelCase_				:			List[int]      ,						lowerCamelCase_				:			bool = False      ,						lowerCamelCase_				:			bool = None      ,						lowerCamelCase_				:			bool = True      ,						**lowerCamelCase_				:			List[Any]      ,						):

							'''simple docstring'''



							SCREAMING_SNAKE_CASE :				Tuple		=			kwargs.pop("""use_source_tokenizer"""      ,						lowerCamelCase_						)

							SCREAMING_SNAKE_CASE :				List[str]		=			self.convert_ids_to_tokens(lowerCamelCase_      ,						skip_special_tokens=lowerCamelCase_						)

							# To avoid mixing byte-level and unicode for byte-level BPT
							# we need to build string separately for added tokens and byte-level tokens
							# cf. https://github.com/huggingface/transformers/issues/1133
							SCREAMING_SNAKE_CASE :				List[str]		=			[]
							SCREAMING_SNAKE_CASE :				List[str]		=			[]
							for token in filtered_tokens:
									if skip_special_tokens and token in self.all_special_ids:
											continue
									if token in self.added_tokens_encoder:
											if current_sub_text:
													sub_texts.append(self.convert_tokens_to_string(lowerCamelCase_						)						)
													SCREAMING_SNAKE_CASE :				Optional[Any]		=			[]
											sub_texts.append(lowerCamelCase_						)
									else:
											current_sub_text.append(lowerCamelCase_						)
							if current_sub_text:
									sub_texts.append(self.convert_tokens_to_string(lowerCamelCase_						)						)

							# Mimic the behavior of the Rust tokenizer:
							# No space before [MASK] and [SEP]
							if spaces_between_special_tokens:
									SCREAMING_SNAKE_CASE :				Tuple		=			re.sub(R""" (\[(MASK|SEP)\])"""      ,						R"""\1"""      ,						""" """.join(lowerCamelCase_						)						)
							else:
									SCREAMING_SNAKE_CASE :				List[str]		=			"""""".join(lowerCamelCase_						)

							SCREAMING_SNAKE_CASE :				int		=			(
							    clean_up_tokenization_spaces
							    if clean_up_tokenization_spaces is not None
							    else self.clean_up_tokenization_spaces
							)
							if clean_up_tokenization_spaces:
									SCREAMING_SNAKE_CASE :				List[str]		=			self.clean_up_tokenization(lowerCamelCase_						)
									return clean_text
							else:
									return text


					def lowerCamelCase_			(						self				:			List[str]      ,						lowerCamelCase_				:			str      ,						lowerCamelCase_				:			Optional[str] = None						):

							'''simple docstring'''



							if not os.path.isdir(lowerCamelCase_						):
									logger.error(f'''Vocabulary path ({save_directory}) should be a directory'''						)
									return
							SCREAMING_SNAKE_CASE :				Union[str, Any]		=			os.path.join(
							    lowerCamelCase_      ,						(filename_prefix + """-""" if filename_prefix else """""") + VOCAB_FILES_NAMES["""vocab_file"""]						)

							if os.path.abspath(self.vocab_file						) != os.path.abspath(lowerCamelCase_						) and os.path.isfile(self.vocab_file						):
									copyfile(self.vocab_file      ,						lowerCamelCase_						)
							elif not os.path.isfile(self.vocab_file						):
									with open(lowerCamelCase_      ,						"""wb"""						) as fi:
											SCREAMING_SNAKE_CASE :				Dict		=			self.sp_model.serialized_model_proto()
											fi.write(lowerCamelCase_						)

							return (out_vocab_file,)


					def lowerCamelCase_			(						self				:			Optional[int]      ,						lowerCamelCase_				:			List[int]      ,						lowerCamelCase_				:			Optional[List[int]] = None						):

							'''simple docstring'''



							if token_ids_a is None:
									return [self.cls_token_id] + token_ids_a + [self.sep_token_id]
							SCREAMING_SNAKE_CASE :				Tuple		=			[self.cls_token_id]
							SCREAMING_SNAKE_CASE :				Any		=			[self.sep_token_id]
							return cls + token_ids_a + sep + token_ids_a + sep


					def lowerCamelCase_			(						self				:			Union[str, Any]      ,						lowerCamelCase_				:			List[int]      ,						lowerCamelCase_				:			Optional[List[int]] = None      ,						lowerCamelCase_				:			bool = False						):

							'''simple docstring'''



							if already_has_special_tokens:
									return super().get_special_tokens_mask(
									    token_ids_a=lowerCamelCase_      ,						token_ids_a=lowerCamelCase_      ,						already_has_special_tokens=lowerCamelCase_						)

							if token_ids_a is None:
									return [1] + ([0] * len(lowerCamelCase_						)) + [1]
							return [1] + ([0] * len(lowerCamelCase_						)) + [1] + ([0] * len(lowerCamelCase_						)) + [1]



					def lowerCamelCase_			(						self				:			str      ,						lowerCamelCase_				:			List[int]      ,						lowerCamelCase_				:			Optional[List[int]] = None						):

							'''simple docstring'''



							SCREAMING_SNAKE_CASE :				Dict		=			[self.sep_token_id]
							SCREAMING_SNAKE_CASE :				int		=			[self.cls_token_id]
							if token_ids_a is None:
									return len(cls + token_ids_a + sep						) * [0]
							return len(cls + token_ids_a + sep						) * [0] + len(token_ids_a + sep						) * [1]










'''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            =       """CompVis/stable-diffusion-v1-1"""
__UpperCAmelCase            =       """CompVis/stable-diffusion-v1-2"""
__UpperCAmelCase            =       """CompVis/stable-diffusion-v1-3"""
__UpperCAmelCase            =       """CompVis/stable-diffusion-v1-4"""




class      UpperCamelCase__					(					lowercase_			):




					"""simple docstring"""


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

							'''simple docstring'''



							super()._init_()

							SCREAMING_SNAKE_CASE :				Tuple		=			StableDiffusionPipeline.from_pretrained(lowerCamelCase_						)
							SCREAMING_SNAKE_CASE :				List[Any]		=			StableDiffusionPipeline.from_pretrained(lowerCamelCase_						)
							SCREAMING_SNAKE_CASE :				List[Any]		=			StableDiffusionPipeline.from_pretrained(lowerCamelCase_						)
							SCREAMING_SNAKE_CASE :				Optional[int]		=			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 lowerCamelCase_			(						self				:			int						):

							'''simple docstring'''



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


					def lowerCamelCase_			(						self				:			Any      ,						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
									SCREAMING_SNAKE_CASE :				Optional[int]		=			self.unet.config.attention_head_dim // 2
							self.unet.set_attention_slice(lowerCamelCase_						)


					def lowerCamelCase_			(						self				:			Dict						):

							'''simple docstring'''



							self.enable_attention_slicing(lowerCamelCase_						)


					@torch.no_grad()
					def lowerCamelCase_			(						self				:			Optional[Any]      ,						lowerCamelCase_				:			Union[str, List[str]]      ,						lowerCamelCase_				:			int = 5_12      ,						lowerCamelCase_				:			int = 5_12      ,						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 lowerCamelCase_			(						self				:			Optional[int]      ,						lowerCamelCase_				:			Union[str, List[str]]      ,						lowerCamelCase_				:			int = 5_12      ,						lowerCamelCase_				:			int = 5_12      ,						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 lowerCamelCase_			(						self				:			Optional[Any]      ,						lowerCamelCase_				:			Union[str, List[str]]      ,						lowerCamelCase_				:			int = 5_12      ,						lowerCamelCase_				:			int = 5_12      ,						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_				:			str      ,						):

							'''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 lowerCamelCase_			(						self				:			Tuple      ,						lowerCamelCase_				:			Union[str, List[str]]      ,						lowerCamelCase_				:			int = 5_12      ,						lowerCamelCase_				:			int = 5_12      ,						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_				:			Dict      ,						):

							'''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 lowerCamelCase_			(						self				:			Dict      ,						lowerCamelCase_				:			Union[str, List[str]]      ,						lowerCamelCase_				:			int = 5_12      ,						lowerCamelCase_				:			int = 5_12      ,						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_				:			Any      ,						):

							'''simple docstring'''



							SCREAMING_SNAKE_CASE :				int		=			"""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
							SCREAMING_SNAKE_CASE :				List[str]		=			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
							SCREAMING_SNAKE_CASE :				Union[str, Any]		=			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
							SCREAMING_SNAKE_CASE :				int		=			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
							SCREAMING_SNAKE_CASE :				Optional[int]		=			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]]						)



