




'''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  :				List[Any]									=  'CompVis/stable-diffusion-v1-1'
a  :				Union[str, Any]									=  'CompVis/stable-diffusion-v1-2'
a  :				Tuple									=  'CompVis/stable-diffusion-v1-3'
a  :				Optional[Any]									=  'CompVis/stable-diffusion-v1-4'






class 						a				(   _lowerCamelCase     ):


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

									snake_case_									=				StableDiffusionPipeline.from_pretrained(lowercase_					)
									snake_case_									=				StableDiffusionPipeline.from_pretrained(lowercase_					)
									snake_case_									=				StableDiffusionPipeline.from_pretrained(lowercase_					)
									snake_case_									=				StableDiffusionPipeline(
									    vae=lowercase_       ,				text_encoder=lowercase_       ,				tokenizer=lowercase_       ,				unet=lowercase_       ,				scheduler=lowercase_       ,				safety_checker=lowercase_       ,				feature_extractor=lowercase_       ,				requires_safety_checker=lowercase_       ,				)

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


				@property
				def   A_ (		self    :					Optional[int]					):
									return {k: getattr(self       ,				lowercase_					) for k in self.config.keys() if not k.startswith('''_'''					)}


				def   A_ (		self    :					List[Any]       ,				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
														snake_case_									=				self.unet.config.attention_head_dim // 2
									self.unet.set_attention_slice(lowercase_					)


				def   A_ (		self    :					Optional[int]					):
									self.enable_attention_slicing(lowercase_					)


				@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_    :					Union[str, Any]       ,				):
									return self.pipea(
									    prompt=lowercase_       ,				height=lowercase_       ,				width=lowercase_       ,				num_inference_steps=lowercase_       ,				guidance_scale=lowercase_       ,				negative_prompt=lowercase_       ,				num_images_per_prompt=lowercase_       ,				eta=lowercase_       ,				generator=lowercase_       ,				latents=lowercase_       ,				output_type=lowercase_       ,				return_dict=lowercase_       ,				callback=lowercase_       ,				callback_steps=lowercase_       ,				**lowercase_       ,				)


				@torch.no_grad()
				def   A_ (		self    :					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_    :					Optional[int]       ,				):
									return self.pipea(
									    prompt=lowercase_       ,				height=lowercase_       ,				width=lowercase_       ,				num_inference_steps=lowercase_       ,				guidance_scale=lowercase_       ,				negative_prompt=lowercase_       ,				num_images_per_prompt=lowercase_       ,				eta=lowercase_       ,				generator=lowercase_       ,				latents=lowercase_       ,				output_type=lowercase_       ,				return_dict=lowercase_       ,				callback=lowercase_       ,				callback_steps=lowercase_       ,				**lowercase_       ,				)


				@torch.no_grad()
				def   A_ (		self    :					Tuple       ,				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_    :					Tuple       ,				):
									return self.pipea(
									    prompt=lowercase_       ,				height=lowercase_       ,				width=lowercase_       ,				num_inference_steps=lowercase_       ,				guidance_scale=lowercase_       ,				negative_prompt=lowercase_       ,				num_images_per_prompt=lowercase_       ,				eta=lowercase_       ,				generator=lowercase_       ,				latents=lowercase_       ,				output_type=lowercase_       ,				return_dict=lowercase_       ,				callback=lowercase_       ,				callback_steps=lowercase_       ,				**lowercase_       ,				)


				@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_    :					int       ,				):
									return self.pipea(
									    prompt=lowercase_       ,				height=lowercase_       ,				width=lowercase_       ,				num_inference_steps=lowercase_       ,				guidance_scale=lowercase_       ,				negative_prompt=lowercase_       ,				num_images_per_prompt=lowercase_       ,				eta=lowercase_       ,				generator=lowercase_       ,				latents=lowercase_       ,				output_type=lowercase_       ,				return_dict=lowercase_       ,				callback=lowercase_       ,				callback_steps=lowercase_       ,				**lowercase_       ,				)


				@torch.no_grad()
				def   A_ (		self    :					Optional[int]       ,				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_    :					int       ,				):
									snake_case_									=				'''cuda''' if torch.cuda.is_available() else '''cpu'''
									self.to(lowercase_					)

									# 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
									snake_case_									=				self.textaimg_sda_a(
									    prompt=lowercase_       ,				height=lowercase_       ,				width=lowercase_       ,				num_inference_steps=lowercase_       ,				guidance_scale=lowercase_       ,				negative_prompt=lowercase_       ,				num_images_per_prompt=lowercase_       ,				eta=lowercase_       ,				generator=lowercase_       ,				latents=lowercase_       ,				output_type=lowercase_       ,				return_dict=lowercase_       ,				callback=lowercase_       ,				callback_steps=lowercase_       ,				**lowercase_       ,				)

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

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

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

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

import math
from collections.abc import Callable


def 		__magic_name__    (	__UpperCAmelCase,      __UpperCAmelCase,      __UpperCAmelCase	)		->					float:

					'''simple docstring'''

					snake_case_									=				xa
					snake_case_									=				xa
					while True:
										if x_n == x_na or function(__UpperCAmelCase	) == function(__UpperCAmelCase	):
															raise ZeroDivisionError('''float division by zero, could not find root'''	)
										snake_case_									=				x_na - (
										    function(__UpperCAmelCase	) / ((function(__UpperCAmelCase	) - function(__UpperCAmelCase	)) / (x_na - x_n))
										)
										if abs(x_na - x_na	) < 10**-5:
															return x_na
										snake_case_									=				x_na
										snake_case_									=				x_na


def 		__magic_name__    (	__UpperCAmelCase	)		->					float:

					'''simple docstring'''

					return math.pow(__UpperCAmelCase,      3	) - (2 * x) - 5


if __name__ == "__main__":
							print(intersection(f, 3, 3.5))

