


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





class       A    (   A_ ):


							def __init__(self      ,				lowerCAmelCase      ,				lowerCAmelCase      ,				lowerCAmelCase      ,				lowerCAmelCase      ,				lowerCAmelCase      ,				lowerCAmelCase      ,				lowerCAmelCase      ,				lowerCAmelCase = True      ,				):
									super()._init_()

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


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


							def 			_A       (self					):
									self.enable_attention_slicing(lowerCAmelCase					)


							@torch.no_grad()
							def 			_A       (self      ,				lowerCAmelCase      ,				lowerCAmelCase = 5_1_2      ,				lowerCAmelCase = 5_1_2      ,				lowerCAmelCase = 5_0      ,				lowerCAmelCase = 7.5      ,				lowerCAmelCase = None      ,				lowerCAmelCase = 1      ,				lowerCAmelCase = 0.0      ,				lowerCAmelCase = None      ,				lowerCAmelCase = None      ,				lowerCAmelCase = "pil"      ,				lowerCAmelCase = True      ,				lowerCAmelCase = None      ,				lowerCAmelCase = 1      ,				**lowerCAmelCase      ,				):
									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 			_A       (self      ,				lowerCAmelCase      ,				lowerCAmelCase = 5_1_2      ,				lowerCAmelCase = 5_1_2      ,				lowerCAmelCase = 5_0      ,				lowerCAmelCase = 7.5      ,				lowerCAmelCase = None      ,				lowerCAmelCase = 1      ,				lowerCAmelCase = 0.0      ,				lowerCAmelCase = None      ,				lowerCAmelCase = None      ,				lowerCAmelCase = "pil"      ,				lowerCAmelCase = True      ,				lowerCAmelCase = None      ,				lowerCAmelCase = 1      ,				**lowerCAmelCase      ,				):
									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 			_A       (self      ,				lowerCAmelCase      ,				lowerCAmelCase = 5_1_2      ,				lowerCAmelCase = 5_1_2      ,				lowerCAmelCase = 5_0      ,				lowerCAmelCase = 7.5      ,				lowerCAmelCase = None      ,				lowerCAmelCase = 1      ,				lowerCAmelCase = 0.0      ,				lowerCAmelCase = None      ,				lowerCAmelCase = None      ,				lowerCAmelCase = "pil"      ,				lowerCAmelCase = True      ,				lowerCAmelCase = None      ,				lowerCAmelCase = 1      ,				**lowerCAmelCase      ,				):
									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 			_A       (self      ,				lowerCAmelCase      ,				lowerCAmelCase = 5_1_2      ,				lowerCAmelCase = 5_1_2      ,				lowerCAmelCase = 5_0      ,				lowerCAmelCase = 7.5      ,				lowerCAmelCase = None      ,				lowerCAmelCase = 1      ,				lowerCAmelCase = 0.0      ,				lowerCAmelCase = None      ,				lowerCAmelCase = None      ,				lowerCAmelCase = "pil"      ,				lowerCAmelCase = True      ,				lowerCAmelCase = None      ,				lowerCAmelCase = 1      ,				**lowerCAmelCase      ,				):
									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 			_A       (self      ,				lowerCAmelCase      ,				lowerCAmelCase = 5_1_2      ,				lowerCAmelCase = 5_1_2      ,				lowerCAmelCase = 5_0      ,				lowerCAmelCase = 7.5      ,				lowerCAmelCase = None      ,				lowerCAmelCase = 1      ,				lowerCAmelCase = 0.0      ,				lowerCAmelCase = None      ,				lowerCAmelCase = None      ,				lowerCAmelCase = "pil"      ,				lowerCAmelCase = True      ,				lowerCAmelCase = None      ,				lowerCAmelCase = 1      ,				**lowerCAmelCase      ,				):
									__lowercase=			'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
									__lowercase=			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
									__lowercase=			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
									__lowercase=			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
									__lowercase=			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]]					)










def        _lowerCamelCase(	lowercase__	)						->	int:

		'''simple docstring'''







		if collection == []:
				return []

		# get some information about the collection
		__lowercase=			len(lowercase__	)
		__lowercase=			max(lowercase__	)
		__lowercase=			min(lowercase__	)

		# create the counting array
		__lowercase=			coll_max + 1 - coll_min
		__lowercase=			[0] * counting_arr_length

		# count how much a number appears in the collection
		for number in collection:
				counting_arr[number - coll_min] += 1

		# sum each position with it's predecessors. now, counting_arr[i] tells
		# us how many elements <= i has in the collection
		for i in range(1   , lowercase__	):
				__lowercase=			counting_arr[i] + counting_arr[i - 1]

		# create the output collection
		__lowercase=			[0] * coll_len

		# place the elements in the output, respecting the original order (stable
		# sort) from end to begin, updating counting_arr
		for i in reversed(range(0   , lowercase__	)	):
				__lowercase=			collection[i]
				counting_arr[collection[i] - coll_min] -= 1

		return ordered







def        _lowerCamelCase(	lowercase__	)						->	List[str]:

		'''simple docstring'''







		return "".join([chr(lowercase__	) for i in counting_sort([ord(lowercase__	) for c in string]	)]	)


if __name__ == "__main__":
	# Test string sort
	assert counting_sort_string('''thisisthestring''') == "eghhiiinrsssttt"

	lowerCAmelCase           =		input('''Enter numbers separated by a comma:\n''').strip()
	lowerCAmelCase           =		[int(item) for item in user_input.split(''',''')]
	print(counting_sort(unsorted))






