




import gc
import tempfile
import unittest

import numpy as np
import torch

from diffusers import VersatileDiffusionTextToImagePipeline
from diffusers.utils.testing_utils import nightly, require_torch_gpu, torch_device


a													=			False




class       _A				(		unittest.TestCase     ):
		pass




@nightly
@require_torch_gpu
class       _A				(		unittest.TestCase     ):






		def 				UpperCAmelCase (    self			):
								# clean up the VRAM after each test
								super().tearDown()
								gc.collect()
								torch.cuda.empty_cache()






		def 				UpperCAmelCase (    self			):
								_UpperCAmelCase      =			VersatileDiffusionTextToImagePipeline.from_pretrained("""shi-labs/versatile-diffusion"""			)
								# remove text_unet
								pipe.remove_unused_weights()
								pipe.to(SCREAMING_SNAKE_CASE_			)
								pipe.set_progress_bar_config(disable=SCREAMING_SNAKE_CASE_			)

								_UpperCAmelCase      =			"""A painting of a squirrel eating a burger """
								_UpperCAmelCase      =			torch.manual_seed(0			)
								_UpperCAmelCase      =			pipe(
								    prompt=SCREAMING_SNAKE_CASE_						,		generator=SCREAMING_SNAKE_CASE_						,		guidance_scale=7.5						,		num_inference_steps=2						,		output_type="""numpy"""			).images

								with tempfile.TemporaryDirectory() as tmpdirname:
														pipe.save_pretrained(SCREAMING_SNAKE_CASE_			)
														_UpperCAmelCase      =			VersatileDiffusionTextToImagePipeline.from_pretrained(SCREAMING_SNAKE_CASE_			)
								pipe.to(SCREAMING_SNAKE_CASE_			)
								pipe.set_progress_bar_config(disable=SCREAMING_SNAKE_CASE_			)

								_UpperCAmelCase      =			generator.manual_seed(0			)
								_UpperCAmelCase      =			pipe(
								    prompt=SCREAMING_SNAKE_CASE_						,		generator=SCREAMING_SNAKE_CASE_						,		guidance_scale=7.5						,		num_inference_steps=2						,		output_type="""numpy"""			).images

								assert np.abs(image - new_image			).sum() < 1e-5, "Models don't have the same forward pass"






		def 				UpperCAmelCase (    self			):
								_UpperCAmelCase      =			VersatileDiffusionTextToImagePipeline.from_pretrained(
								    """shi-labs/versatile-diffusion"""						,		torch_dtype=torch.floataa			)
								pipe.to(SCREAMING_SNAKE_CASE_			)
								pipe.set_progress_bar_config(disable=SCREAMING_SNAKE_CASE_			)

								_UpperCAmelCase      =			"""A painting of a squirrel eating a burger """
								_UpperCAmelCase      =			torch.manual_seed(0			)
								_UpperCAmelCase      =			pipe(
								    prompt=SCREAMING_SNAKE_CASE_						,		generator=SCREAMING_SNAKE_CASE_						,		guidance_scale=7.5						,		num_inference_steps=50						,		output_type="""numpy"""			).images

								_UpperCAmelCase      =			image[0, 253:256, 253:256, -1]

								assert image.shape == (1, 512, 512, 3)
								_UpperCAmelCase      =			np.array([0.3367, 0.3169, 0.2656, 0.3870, 0.4790, 0.3796, 0.4009, 0.4878, 0.4778]			)

								assert np.abs(image_slice.flatten() - expected_slice			).max() < 1e-2





from __future__ import annotations




def        _SCREAMING_SNAKE_CASE      (		snake_case       )						->				list[int]:
						if len(snake_case       ) == 0:
												return array

						_UpperCAmelCase    ,					_UpperCAmelCase      =			min(snake_case       ), max(snake_case       )

						# Compute the variables
						_UpperCAmelCase      =			_max - _min + 1
						_UpperCAmelCase    ,					_UpperCAmelCase      =			[0] * holes_range, [0] * holes_range

						# Make the sorting.
						for i in array:
												_UpperCAmelCase      =			i - _min
												_UpperCAmelCase      =			i
												holes_repeat[index] += 1

						# Makes the array back by replacing the numbers.
						_UpperCAmelCase      =			0
						for i in range(snake_case       ):
												while holes_repeat[i] > 0:
																		_UpperCAmelCase      =			holes[i]
																		index += 1
																		holes_repeat[i] -= 1

    # Returns the sorted array.
						return array


if __name__ == "__main__":
				import doctest

				doctest.testmod()
				a													=			input("Enter numbers separated by comma:\n")
				a													=			[int(x) for x in user_input.split(",")]
				print(pigeon_sort(unsorted))