


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


a_						:       Any      			=				"""CompVis/stable-diffusion-v1-1"""
a_						:       Optional[Any]      			=				"""CompVis/stable-diffusion-v1-2"""
a_						:       Tuple      			=				"""CompVis/stable-diffusion-v1-3"""
a_						:       Optional[int]      			=				"""CompVis/stable-diffusion-v1-4"""





class   snake_case					(					lowercase    ):





  """simple docstring"""




  def __init__(					self    ,						UpperCamelCase    ,						UpperCamelCase    ,						UpperCamelCase    ,						UpperCamelCase    ,						UpperCamelCase    ,						UpperCamelCase    ,						UpperCamelCase    ,						UpperCamelCase = True    ,						):







   """simple docstring"""
   super()._init_()

   lowerCamelCase_  				=						StableDiffusionPipeline.from_pretrained(UpperCamelCase  )
   lowerCamelCase_  				=						StableDiffusionPipeline.from_pretrained(UpperCamelCase  )
   lowerCamelCase_  				=						StableDiffusionPipeline.from_pretrained(UpperCamelCase  )
   lowerCamelCase_  				=						StableDiffusionPipeline(
       vae=UpperCamelCase    ,						text_encoder=UpperCamelCase    ,						tokenizer=UpperCamelCase    ,						unet=UpperCamelCase    ,						scheduler=UpperCamelCase    ,						safety_checker=UpperCamelCase    ,						feature_extractor=UpperCamelCase    ,						requires_safety_checker=UpperCamelCase    ,						)

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






  @property
  def 						snake_case	(					self  ):







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






  def 						snake_case	(					self    ,						UpperCamelCase = "auto"  ):







   """simple docstring"""
   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(UpperCamelCase  )






  def 						snake_case	(					self  ):







   """simple docstring"""
   self.enable_attention_slicing(UpperCamelCase  )






  @torch.no_grad()
  def 						snake_case	(					self    ,						UpperCamelCase    ,						UpperCamelCase = 512    ,						UpperCamelCase = 512    ,						UpperCamelCase = 50    ,						UpperCamelCase = 7.5    ,						UpperCamelCase = None    ,						UpperCamelCase = 1    ,						UpperCamelCase = 0.0    ,						UpperCamelCase = None    ,						UpperCamelCase = None    ,						UpperCamelCase = "pil"    ,						UpperCamelCase = True    ,						UpperCamelCase = None    ,						UpperCamelCase = 1    ,						**UpperCamelCase    ,						):







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






  @torch.no_grad()
  def 						snake_case	(					self    ,						UpperCamelCase    ,						UpperCamelCase = 512    ,						UpperCamelCase = 512    ,						UpperCamelCase = 50    ,						UpperCamelCase = 7.5    ,						UpperCamelCase = None    ,						UpperCamelCase = 1    ,						UpperCamelCase = 0.0    ,						UpperCamelCase = None    ,						UpperCamelCase = None    ,						UpperCamelCase = "pil"    ,						UpperCamelCase = True    ,						UpperCamelCase = None    ,						UpperCamelCase = 1    ,						**UpperCamelCase    ,						):







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






  @torch.no_grad()
  def 						snake_case	(					self    ,						UpperCamelCase    ,						UpperCamelCase = 512    ,						UpperCamelCase = 512    ,						UpperCamelCase = 50    ,						UpperCamelCase = 7.5    ,						UpperCamelCase = None    ,						UpperCamelCase = 1    ,						UpperCamelCase = 0.0    ,						UpperCamelCase = None    ,						UpperCamelCase = None    ,						UpperCamelCase = "pil"    ,						UpperCamelCase = True    ,						UpperCamelCase = None    ,						UpperCamelCase = 1    ,						**UpperCamelCase    ,						):







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






  @torch.no_grad()
  def 						snake_case	(					self    ,						UpperCamelCase    ,						UpperCamelCase = 512    ,						UpperCamelCase = 512    ,						UpperCamelCase = 50    ,						UpperCamelCase = 7.5    ,						UpperCamelCase = None    ,						UpperCamelCase = 1    ,						UpperCamelCase = 0.0    ,						UpperCamelCase = None    ,						UpperCamelCase = None    ,						UpperCamelCase = "pil"    ,						UpperCamelCase = True    ,						UpperCamelCase = None    ,						UpperCamelCase = 1    ,						**UpperCamelCase    ,						):







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







  @torch.no_grad()
  def 						snake_case	(					self    ,						UpperCamelCase    ,						UpperCamelCase = 512    ,						UpperCamelCase = 512    ,						UpperCamelCase = 50    ,						UpperCamelCase = 7.5    ,						UpperCamelCase = None    ,						UpperCamelCase = 1    ,						UpperCamelCase = 0.0    ,						UpperCamelCase = None    ,						UpperCamelCase = None    ,						UpperCamelCase = "pil"    ,						UpperCamelCase = True    ,						UpperCamelCase = None    ,						UpperCamelCase = 1    ,						**UpperCamelCase    ,						):







   """simple docstring"""
   lowerCamelCase_  				=						"cuda" if torch.cuda.is_available() else "cpu"
   self.to(UpperCamelCase  )

   # 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=UpperCamelCase    ,						height=UpperCamelCase    ,						width=UpperCamelCase    ,						num_inference_steps=UpperCamelCase    ,						guidance_scale=UpperCamelCase    ,						negative_prompt=UpperCamelCase    ,						num_images_per_prompt=UpperCamelCase    ,						eta=UpperCamelCase    ,						generator=UpperCamelCase    ,						latents=UpperCamelCase    ,						output_type=UpperCamelCase    ,						return_dict=UpperCamelCase    ,						callback=UpperCamelCase    ,						callback_steps=UpperCamelCase    ,						**UpperCamelCase    ,						)

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

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

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

   # 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_		:		int = 100	):
 lowerCamelCase_  				=						n * (n + 1) * (2 * n + 1) / 6
 lowerCamelCase_  				=						(n * (n + 1) / 2) ** 2
 return int(square_of_sum - sum_of_squares	)


if __name__ == "__main__":
     print(f'''{solution() = }''')



