





import unittest

import numpy as np
import PIL
import torch

from diffusers.image_processor import VaeImageProcessor







class 	_UpperCamelCase	(							unittest.TestCase	):







					'''simple docstring'''

					@property
					def 							SCREAMING_SNAKE_CASE				(    self     :	Union[str, Any]		):






						'''simple docstring'''







						UpperCAmelCase_		    =  1
						UpperCAmelCase_		    =  3
						UpperCAmelCase_		    =  8
						UpperCAmelCase_		    =  8

						UpperCAmelCase_		    =  torch.rand((batch_size, num_channels, height, width)		)

						return sample





					def 							SCREAMING_SNAKE_CASE				(    self     :	int			,       __lowercase     :	Optional[Any]		):






						'''simple docstring'''







						if isinstance(image[0]			,       PIL.Image.Image		):
							return np.stack([np.array(__lowercase		) for i in image]			,       axis=0		)
						elif isinstance(__lowercase			,       torch.Tensor		):
							return image.cpu().numpy().transpose(0			,       2			,       3			,       1		)
						return image





					def 							SCREAMING_SNAKE_CASE				(    self     :	Dict		):






						'''simple docstring'''







						UpperCAmelCase_		    =  VaeImageProcessor(do_resize=__lowercase			,       do_normalize=__lowercase		)

						UpperCAmelCase_		    =  self.dummy_sample
						UpperCAmelCase_		    =  self.to_np(__lowercase		)

						for output_type in ["pt", "np", "pil"]:
							UpperCAmelCase_		    =  image_processor.postprocess(
							    image_processor.preprocess(__lowercase		)			,       output_type=__lowercase			,       )
							UpperCAmelCase_		    =  self.to_np(__lowercase		)
							UpperCAmelCase_		    =  (input_np * 2_55).round() if output_type == """pil""" else input_np
							assert (
							    np.abs(in_np - out_np		).max() < 1e-6
							), F"""decoded output does not match input for output_type {output_type}"""





					def 							SCREAMING_SNAKE_CASE				(    self     :	Tuple		):






						'''simple docstring'''







						UpperCAmelCase_		    =  VaeImageProcessor(do_resize=__lowercase			,       do_normalize=__lowercase		)
						UpperCAmelCase_		    =  self.dummy_sample.cpu().numpy().transpose(0			,       2			,       3			,       1		)

						for output_type in ["pt", "np", "pil"]:
							UpperCAmelCase_		    =  image_processor.postprocess(image_processor.preprocess(__lowercase		)			,       output_type=__lowercase		)

							UpperCAmelCase_		    =  self.to_np(__lowercase		)
							UpperCAmelCase_		    =  (input_np * 2_55).round() if output_type == """pil""" else input_np
							assert (
							    np.abs(in_np - out_np		).max() < 1e-6
							), F"""decoded output does not match input for output_type {output_type}"""





					def 							SCREAMING_SNAKE_CASE				(    self     :	List[str]		):






						'''simple docstring'''







						UpperCAmelCase_		    =  VaeImageProcessor(do_resize=__lowercase			,       do_normalize=__lowercase		)

						UpperCAmelCase_		    =  self.dummy_sample.cpu().numpy().transpose(0			,       2			,       3			,       1		)
						UpperCAmelCase_		    =  image_processor.numpy_to_pil(__lowercase		)

						for output_type in ["pt", "np", "pil"]:
							UpperCAmelCase_		    =  image_processor.postprocess(image_processor.preprocess(__lowercase		)			,       output_type=__lowercase		)
							for i, o in zip(__lowercase			,       __lowercase		):
								UpperCAmelCase_		    =  np.array(__lowercase		)
								UpperCAmelCase_		    =  self.to_np(__lowercase		) if output_type == """pil""" else (self.to_np(__lowercase		) * 2_55).round()
								assert (
								    np.abs(in_np - out_np		).max() < 1e-6
								), F"""decoded output does not match input for output_type {output_type}"""





					def 							SCREAMING_SNAKE_CASE				(    self     :	Any		):






						'''simple docstring'''







						UpperCAmelCase_		    =  VaeImageProcessor(do_resize=__lowercase			,       do_normalize=__lowercase		)

						UpperCAmelCase_		    =  self.dummy_sample
						UpperCAmelCase_		    =  input_pt_ad.squeeze(0		)

						UpperCAmelCase_		    =  image_processor.postprocess(
						    image_processor.preprocess(__lowercase		)			,       output_type="""np"""			,       )
						UpperCAmelCase_		    =  image_processor.postprocess(
						    image_processor.preprocess(__lowercase		)			,       output_type="""np"""			,       )

						UpperCAmelCase_		    =  self.to_np(self.dummy_sample		)
						UpperCAmelCase_		    =  input_np_ad.squeeze(0		)

						UpperCAmelCase_		    =  image_processor.postprocess(
						    image_processor.preprocess(__lowercase		)			,       output_type="""np"""			,       )
						UpperCAmelCase_		    =  image_processor.postprocess(
						    image_processor.preprocess(__lowercase		)			,       output_type="""np"""			,       )

						assert np.abs(out_pt_ad - out_pt_ad		).max() < 1e-6
						assert np.abs(out_np_ad - out_np_ad		).max() < 1e-6





					def 							SCREAMING_SNAKE_CASE				(    self     :	Optional[Any]		):






						'''simple docstring'''







						UpperCAmelCase_		    =  VaeImageProcessor(do_resize=__lowercase			,       do_normalize=__lowercase		)

						UpperCAmelCase_		    =  self.dummy_sample
						UpperCAmelCase_		    =  list(__lowercase		)

						UpperCAmelCase_		    =  image_processor.postprocess(
						    image_processor.preprocess(__lowercase		)			,       output_type="""np"""			,       )

						UpperCAmelCase_		    =  image_processor.postprocess(
						    image_processor.preprocess(__lowercase		)			,       output_type="""np"""			,       )

						UpperCAmelCase_		    =  self.to_np(self.dummy_sample		)
						list(__lowercase		)

						UpperCAmelCase_		    =  image_processor.postprocess(
						    image_processor.preprocess(__lowercase		)			,       output_type="""np"""			,       )

						UpperCAmelCase_		    =  image_processor.postprocess(
						    image_processor.preprocess(__lowercase		)			,       output_type="""np"""			,       )

						assert np.abs(out_pt_ad - out_pt_list		).max() < 1e-6
						assert np.abs(out_np_ad - out_np_list		).max() < 1e-6









def  A_(      A = 1000 ):
	UpperCAmelCase_		    =  0
	for i in range(A ):
		if i % 3 == 0 or i % 5 == 0:
			result += i
	return result


if __name__ == "__main__":
				print(f"{solution() = }")


