


# Algorithm for the pigeonhole sorting




def 			UpperCAmelCase_				(      UpperCAmelCase__  ):
					lowercase_  							=			min(UpperCAmelCase__  )  # min() finds the minimum value
					lowercase_  							=			max(UpperCAmelCase__  )  # max() finds the maximum value

					lowercase_  							=			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
					lowercase_  							=			[0] * size

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

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


def 			UpperCAmelCase_				(      ):
					lowercase_  							=			[8, 3, 2, 7, 4, 6, 8]
					pigeonhole_sort(UpperCAmelCase__  )
					print("""Sorted order is:"""						,							""" """.join(UpperCAmelCase__  )  )


if __name__ == "__main__":
							main()






import PIL.Image
import PIL.ImageOps
from packaging import version
from PIL import Image


if version.parse(version.parse(PIL.__version__).base_version) >= version.parse('9.1.0'):
							a					  =     {
							    'linear': PIL.Image.Resampling.BILINEAR,
							    'bilinear': PIL.Image.Resampling.BILINEAR,
							    'bicubic': PIL.Image.Resampling.BICUBIC,
							    'lanczos': PIL.Image.Resampling.LANCZOS,
							    'nearest': PIL.Image.Resampling.NEAREST,
							}
else:
							a					  =     {
							    'linear': PIL.Image.LINEAR,
							    'bilinear': PIL.Image.BILINEAR,
							    'bicubic': PIL.Image.BICUBIC,
							    'lanczos': PIL.Image.LANCZOS,
							    'nearest': PIL.Image.NEAREST,
							}


def 			UpperCAmelCase_				(      UpperCAmelCase__  ):
					lowercase_  							=			(images / 2 + 0.5).clamp(0						,							1  )
					lowercase_  							=			images.cpu().permute(0						,							2						,							3						,							1  ).float().numpy()
					lowercase_  							=			numpy_to_pil(UpperCAmelCase__  )
					return images



def 			UpperCAmelCase_				(      UpperCAmelCase__  ):
					if images.ndim == 3:
										lowercase_  							=			images[None, ...]
					lowercase_  							=			(images * 2_5_5).round().astype("""uint8"""  )
					if images.shape[-1] == 1:
										# special case for grayscale (single channel) images
										lowercase_  							=			[Image.fromarray(image.squeeze()						,							mode="""L"""  ) for image in images]
					else:
										lowercase_  							=			[Image.fromarray(UpperCAmelCase__  ) for image in images]

					return pil_images


