


def        UpperCAmelCase__	(lowerCAmelCase_       ):




					'''simple docstring'''


					__SCREAMING_SNAKE_CASE						       =    min(SCREAMING_SNAKE_CASE__       )  # min() finds the minimum value
					__SCREAMING_SNAKE_CASE						       =    max(SCREAMING_SNAKE_CASE__       )  # max() finds the maximum value

					__SCREAMING_SNAKE_CASE						       =    max_val - min_val + 1  # size is difference of max and min values plus one

					# list of pigeonholes of size equal to the variable size
					__SCREAMING_SNAKE_CASE						       =    [0] * size

					# Populate the pigeonholes.
					for x in a:
										assert isinstance(SCREAMING_SNAKE_CASE__  ,						SCREAMING_SNAKE_CASE__       ), "integers only please"
										holes[x - min_val] += 1

					# Putting the elements back into the array in an order.
					__SCREAMING_SNAKE_CASE						       =    0
					for count in range(SCREAMING_SNAKE_CASE__       ):
										while holes[count] > 0:
															holes[count] -= 1
															__SCREAMING_SNAKE_CASE						       =    count + min_val
															i += 1




def        UpperCAmelCase__	():




					'''simple docstring'''


					__SCREAMING_SNAKE_CASE						       =    [8, 3, 2, 7, 4, 6, 8]
					pigeonhole_sort(SCREAMING_SNAKE_CASE__       )
					print("Sorted order is:"  ,						" ".join(SCREAMING_SNAKE_CASE__       )       )


if __name__ == "__main__":
		main()




"""simple docstring"""







import random
import unittest

import torch

from diffusers import IFInpaintingSuperResolutionPipeline
from diffusers.utils import floats_tensor
from diffusers.utils.import_utils import is_xformers_available
from diffusers.utils.testing_utils import skip_mps, torch_device

from ..pipeline_params import (
    TEXT_GUIDED_IMAGE_INPAINTING_BATCH_PARAMS,
    TEXT_GUIDED_IMAGE_INPAINTING_PARAMS,
)
from ..test_pipelines_common import PipelineTesterMixin
from . import IFPipelineTesterMixin




@skip_mps
class 			UpperCamelCase_     (			UpperCamelCase      ,  UpperCamelCase      ,  unittest.TestCase):

	"""simple docstring"""





	snake_case__    :  str    =      IFInpaintingSuperResolutionPipeline
	snake_case__    :  Optional[Any]    =      TEXT_GUIDED_IMAGE_INPAINTING_PARAMS - {"width", "height"}
	snake_case__    :  Union[str, Any]    =      TEXT_GUIDED_IMAGE_INPAINTING_BATCH_PARAMS.union({"original_image"})
	snake_case__    :  Dict    =      PipelineTesterMixin.required_optional_params - {"latents"}




	def   UpperCAmelCase_				(			self      :    List[Any]       )	->     Optional[int]:
						return self._get_superresolution_dummy_components()




	def   UpperCAmelCase_				(			self      :    List[str]      ,      UpperCAmelCase__      :    List[Any]      ,      UpperCAmelCase__      :    List[str]=0       )	->     List[str]:
						if str(UpperCAmelCase__       ).startswith("mps"       ):
											__SCREAMING_SNAKE_CASE						       =    torch.manual_seed(UpperCAmelCase__       )
						else:
											__SCREAMING_SNAKE_CASE						       =    torch.Generator(device=UpperCAmelCase__       ).manual_seed(UpperCAmelCase__       )

						__SCREAMING_SNAKE_CASE						       =    floats_tensor((1, 3, 1_6, 1_6)      ,      rng=random.Random(UpperCAmelCase__       )       ).to(UpperCAmelCase__       )
						__SCREAMING_SNAKE_CASE						       =    floats_tensor((1, 3, 3_2, 3_2)      ,      rng=random.Random(UpperCAmelCase__       )       ).to(UpperCAmelCase__       )
						__SCREAMING_SNAKE_CASE						       =    floats_tensor((1, 3, 3_2, 3_2)      ,      rng=random.Random(UpperCAmelCase__       )       ).to(UpperCAmelCase__       )

						__SCREAMING_SNAKE_CASE						       =    {
						    "prompt": "A painting of a squirrel eating a burger",
						    "image": image,
						    "original_image": original_image,
						    "mask_image": mask_image,
						    "generator": generator,
						    "num_inference_steps": 2,
						    "output_type": "numpy",
						}

						return inputs




	@unittest.skipIf(
	    torch_device != "cuda" or not is_xformers_available()      ,      reason="XFormers attention is only available with CUDA and `xformers` installed"      ,      )
	def   UpperCAmelCase_				(			self      :    str       )	->     Dict:
						self._test_xformers_attention_forwardGenerator_pass(expected_max_diff=1E-3       )




	def   UpperCAmelCase_				(			self      :    str       )	->     Tuple:
						self._test_save_load_optional_components()




	@unittest.skipIf(torch_device != "cuda"      ,      reason="float16 requires CUDA"       )
	def   UpperCAmelCase_				(			self      :    Tuple       )	->     Tuple:
						# Due to non-determinism in save load of the hf-internal-testing/tiny-random-t5 text encoder
						super().test_save_load_floataa(expected_max_diff=1E-1       )




	def   UpperCAmelCase_				(			self      :    Optional[Any]       )	->     List[Any]:
						self._test_attention_slicing_forward_pass(expected_max_diff=1E-2       )




	def   UpperCAmelCase_				(			self      :    Any       )	->     Union[str, Any]:
						self._test_save_load_local()




	def   UpperCAmelCase_				(			self      :    Union[str, Any]       )	->     Optional[Any]:
						self._test_inference_batch_single_identical(
						    expected_max_diff=1E-2      ,      )
