code: 
  
  
  
  
  """simple docstring"""
  
  from typing import Dict, List, Optional, Union
  
  import numpy as np
  
  from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict
  from ...image_transforms import center_crop, normalize, rescale, resize, to_channel_dimension_format
  from ...image_utils import (
      IMAGENET_DEFAULT_MEAN,
      IMAGENET_DEFAULT_STD,
      ChannelDimension,
      ImageInput,
      PILImageResampling,
      get_image_size,
      make_list_of_images,
      to_numpy_array,
      valid_images,
  )
  from ...utils import TensorType, is_vision_available, logging
  
  
  if is_vision_available():
  							import PIL
  
  
  __A 		=			logging.get_logger(__name__)
  class 			lowerCamelCase__    (  lowerCamelCase_			):
  			a__ :      List[str]								=     ["""pixel_values"""]
  
  
  			def __init__(     self				, SCREAMING_SNAKE_CASE = True				, SCREAMING_SNAKE_CASE = None				, SCREAMING_SNAKE_CASE = True				, SCREAMING_SNAKE_CASE = None				, SCREAMING_SNAKE_CASE = PILImageResampling.BICUBIC				, SCREAMING_SNAKE_CASE = True				, SCREAMING_SNAKE_CASE = 1 / 255				, SCREAMING_SNAKE_CASE = True				, SCREAMING_SNAKE_CASE = None				, SCREAMING_SNAKE_CASE = None				, **SCREAMING_SNAKE_CASE				, ):
  
  
  
  					"""simple docstring"""
  
  
  
  
  
  
  
  					super().__init__(**SCREAMING_SNAKE_CASE							)
  					snake_case		:						int								=				crop_size if crop_size is not None else {"height": 256, "width": 256}
  					snake_case		:						Union[str, Any]								=				get_size_dict(SCREAMING_SNAKE_CASE				, param_name="crop_size"							)
  					snake_case		:						Tuple								=				size if size is not None else {"height": 224, "width": 224}
  					snake_case		:						Any								=				get_size_dict(SCREAMING_SNAKE_CASE							)
  
  					snake_case		:						Optional[Any]								=				do_center_crop
  					snake_case		:						Tuple								=				crop_size
  					snake_case		:						List[str]								=				do_resize
  					snake_case		:						Tuple								=				size
  					snake_case		:						Tuple								=				resample
  					snake_case		:						Tuple								=				do_rescale
  					snake_case		:						Union[str, Any]								=				rescale_factor
  					snake_case		:						Dict								=				do_normalize
  					snake_case		:						Optional[Any]								=				image_mean if image_mean is not None else IMAGENET_DEFAULT_MEAN
  					snake_case		:						Union[str, Any]								=				image_std if image_std is not None else IMAGENET_DEFAULT_STD
  
  
  			def 							lowerCamelCase_				(     self				, SCREAMING_SNAKE_CASE				, SCREAMING_SNAKE_CASE				, SCREAMING_SNAKE_CASE = None				, SCREAMING_SNAKE_CASE = None				, **SCREAMING_SNAKE_CASE				, ):
  
  
  
  					"""simple docstring"""
  
  
  
  
  
  
  
  					snake_case		:						Optional[int]								=				self.size if size is None else size
  					snake_case		:						List[Any]								=				get_size_dict(SCREAMING_SNAKE_CASE							)
  					snake_case		:						List[Any]								=				get_size_dict(SCREAMING_SNAKE_CASE				, param_name="crop_size"							)
  
  					snake_case			,				snake_case		:						Any								=				get_image_size(SCREAMING_SNAKE_CASE							)
  					snake_case		:						Dict								=				min(SCREAMING_SNAKE_CASE				, SCREAMING_SNAKE_CASE							)
  					snake_case		:						List[str]								=				(size["height"] / crop_size["height"]) * min_dim
  					snake_case		:						Dict								=				(size["width"] / crop_size["width"]) * min_dim
  					return center_crop(SCREAMING_SNAKE_CASE				, size=(cropped_height, cropped_width)				, data_format=SCREAMING_SNAKE_CASE				, **SCREAMING_SNAKE_CASE							)
  
  
  			def 							lowerCamelCase_				(     self				, SCREAMING_SNAKE_CASE				, SCREAMING_SNAKE_CASE				, SCREAMING_SNAKE_CASE = PIL.Image.BICUBIC				, SCREAMING_SNAKE_CASE = None				, **SCREAMING_SNAKE_CASE				, ):
  
  
  
  					"""simple docstring"""
  
  
  
  
  
  
  
  					snake_case		:						int								=				get_size_dict(SCREAMING_SNAKE_CASE							)
  					if "height" not in size or "width" not in size:
  							raise ValueError(F'''The size dictionary must contain the keys \'height\' and \'width\'. Got {size.keys()}'''							)
  					return resize(
  					    SCREAMING_SNAKE_CASE				, size=(size["height"], size["width"])				, resample=SCREAMING_SNAKE_CASE				, data_format=SCREAMING_SNAKE_CASE				, **SCREAMING_SNAKE_CASE							)
  
  
  			def 							lowerCamelCase_				(     self				, SCREAMING_SNAKE_CASE				, SCREAMING_SNAKE_CASE				, SCREAMING_SNAKE_CASE = None				, **SCREAMING_SNAKE_CASE				, ):
  
  
  
  					"""simple docstring"""
  
  
  
  
  
  
  
  					return rescale(SCREAMING_SNAKE_CASE				, scale=SCREAMING_SNAKE_CASE				, data_format=SCREAMING_SNAKE_CASE				, **SCREAMING_SNAKE_CASE							)
  
  
  			def 							lowerCamelCase_				(     self				, SCREAMING_SNAKE_CASE				, SCREAMING_SNAKE_CASE				, SCREAMING_SNAKE_CASE				, SCREAMING_SNAKE_CASE = None				, **SCREAMING_SNAKE_CASE				, ):
  
  
  
  					"""simple docstring"""
  
  
  
  
  
  
  
  					return normalize(SCREAMING_SNAKE_CASE				, mean=SCREAMING_SNAKE_CASE				, std=SCREAMING_SNAKE_CASE				, data_format=SCREAMING_SNAKE_CASE				, **SCREAMING_SNAKE_CASE							)
  
  
  
  			def 							lowerCamelCase_				(     self				, SCREAMING_SNAKE_CASE				, SCREAMING_SNAKE_CASE = None				, SCREAMING_SNAKE_CASE = None				, SCREAMING_SNAKE_CASE = None				, SCREAMING_SNAKE_CASE = None				, SCREAMING_SNAKE_CASE = None				, SCREAMING_SNAKE_CASE = None				, SCREAMING_SNAKE_CASE = None				, SCREAMING_SNAKE_CASE = None				, SCREAMING_SNAKE_CASE = None				, SCREAMING_SNAKE_CASE = None				, SCREAMING_SNAKE_CASE = None				, SCREAMING_SNAKE_CASE = ChannelDimension.FIRST				, **SCREAMING_SNAKE_CASE				, ):
  
  
  
  					"""simple docstring"""
  
  
  
  
  
  
  
  					snake_case		:						Union[str, Any]								=				do_center_crop if do_center_crop is not None else self.do_center_crop
  					snake_case		:						Optional[Any]								=				crop_size if crop_size is not None else self.crop_size
  					snake_case		:						Optional[Any]								=				get_size_dict(SCREAMING_SNAKE_CASE				, param_name="crop_size"							)
  					snake_case		:						Any								=				do_resize if do_resize is not None else self.do_resize
  					snake_case		:						List[str]								=				size if size is not None else self.size
  					snake_case		:						int								=				get_size_dict(SCREAMING_SNAKE_CASE							)
  					snake_case		:						List[str]								=				resample if resample is not None else self.resample
  					snake_case		:						List[Any]								=				do_rescale if do_rescale is not None else self.do_rescale
  					snake_case		:						int								=				rescale_factor if rescale_factor is not None else self.rescale_factor
  					snake_case		:						List[Any]								=				do_normalize if do_normalize is not None else self.do_normalize
  					snake_case		:						List[Any]								=				image_mean if image_mean is not None else self.image_mean
  					snake_case		:						Optional[int]								=				image_std if image_std is not None else self.image_std
  
  					snake_case		:						Union[str, Any]								=				make_list_of_images(SCREAMING_SNAKE_CASE							)
  
  					if not valid_images(SCREAMING_SNAKE_CASE							):
  							raise ValueError(
  							    "Invalid image type. Must be of type PIL.Image.Image, numpy.ndarray, "
  							    "torch.Tensor, tf.Tensor or jax.ndarray."							)
  
  					if do_center_crop and crop_size is None:
  							raise ValueError("If `do_center_crop` is set to `True`, `crop_size` must be provided."							)
  
  					if do_resize and size is None:
  							raise ValueError("Size must be specified if do_resize is True."							)
  
  					if do_rescale and rescale_factor is None:
  							raise ValueError("Rescale factor must be specified if do_rescale is True."							)
  
  					if do_normalize and (image_mean is None or image_std is None):
  							raise ValueError("Image mean and image standard deviation must be specified if do_normalize is True."							)
  
  					# All transformations expect numpy arrays.
  					snake_case		:						int								=				[to_numpy_array(SCREAMING_SNAKE_CASE							) for image in images]
  
  					if do_center_crop:
  							snake_case		:						Optional[int]								=				[self.center_crop(SCREAMING_SNAKE_CASE				, SCREAMING_SNAKE_CASE				, size=SCREAMING_SNAKE_CASE							) for image in images]
  
  					if do_resize:
  							snake_case		:						List[Any]								=				[self.resize(image=SCREAMING_SNAKE_CASE				, size=SCREAMING_SNAKE_CASE				, resample=SCREAMING_SNAKE_CASE							) for image in images]
  
  					if do_rescale:
  							snake_case		:						List[Any]								=				[self.rescale(image=SCREAMING_SNAKE_CASE				, scale=SCREAMING_SNAKE_CASE							) for image in images]
  
  					if do_normalize:
  							snake_case		:						Union[str, Any]								=				[self.normalize(image=SCREAMING_SNAKE_CASE				, mean=SCREAMING_SNAKE_CASE				, std=SCREAMING_SNAKE_CASE							) for image in images]
  
  					snake_case		:						List[Any]								=				[to_channel_dimension_format(SCREAMING_SNAKE_CASE				, SCREAMING_SNAKE_CASE							) for image in images]
  
  					snake_case		:						Dict								=				{"pixel_values": images}
  					return BatchFeature(data=SCREAMING_SNAKE_CASE				, tensor_type=SCREAMING_SNAKE_CASE							)
  
  
style_context: 
  
  
  
  
  """simple docstring"""
  
  import tempfile
  import unittest
  
  from diffusers import (
      DDIMScheduler,
      DDPMScheduler,
      DPMSolverMultistepScheduler,
      EulerAncestralDiscreteScheduler,
      EulerDiscreteScheduler,
      PNDMScheduler,
      logging,
  )
  from diffusers.configuration_utils import ConfigMixin, register_to_config
  from diffusers.utils.testing_utils import CaptureLogger
  class 			lowerCamelCase__    (  lowerCamelCase_			):
  			a__ :      int								=     """config.json"""
  
  
  			@register_to_config
  			def __init__(     self				, SCREAMING_SNAKE_CASE=2				, SCREAMING_SNAKE_CASE=5				, SCREAMING_SNAKE_CASE=(2, 5)				, SCREAMING_SNAKE_CASE="for diffusion"				, SCREAMING_SNAKE_CASE=[1, 3]				, ):
  
  
  
  					"""simple docstring"""
  
  
  
  
  
  
  
  					pass
  
  
  
  
  
  
  
  class 			lowerCamelCase__    (  lowerCamelCase_			):
  			a__ :      Dict								=     """config.json"""
  
  
  			@register_to_config
  			def __init__(     self				, SCREAMING_SNAKE_CASE=2				, SCREAMING_SNAKE_CASE=5				, SCREAMING_SNAKE_CASE=(2, 5)				, SCREAMING_SNAKE_CASE="for diffusion"				, SCREAMING_SNAKE_CASE=[1, 3]				, ):
  
  
  
  					"""simple docstring"""
  
  
  
  
  
  
  
  					pass
  
  
  
  
  
  
  
  class 			lowerCamelCase__    (  lowerCamelCase_			):
  			a__ :      Union[str, Any]								=     """config.json"""
  
  
  			@register_to_config
  			def __init__(     self				, SCREAMING_SNAKE_CASE=2				, SCREAMING_SNAKE_CASE=5				, SCREAMING_SNAKE_CASE=(2, 5)				, SCREAMING_SNAKE_CASE="for diffusion"				, SCREAMING_SNAKE_CASE=[1, 3]				, SCREAMING_SNAKE_CASE=[1, 3]				, ):
  
  
  
  					"""simple docstring"""
  
  
  
  
  
  
  
  					pass
  
  
  
  
  
  
  
  class 			lowerCamelCase__    (  lowerCamelCase_			):
  			a__ :      Tuple								=     """config.json"""
  
  
  			@register_to_config
  			def __init__(     self				, SCREAMING_SNAKE_CASE=2				, SCREAMING_SNAKE_CASE=5				, SCREAMING_SNAKE_CASE=(2, 5)				, SCREAMING_SNAKE_CASE="for diffusion"				, SCREAMING_SNAKE_CASE=[1, 5]				, SCREAMING_SNAKE_CASE=[5, 4]				, ):
  
  
  
  					"""simple docstring"""
  
  
  
  
  
  
  
  					pass
  
  
  
  
  
  
  
  class 			lowerCamelCase__    (  unittest.TestCase			):
  
  
  			def 							lowerCamelCase_				(     self							):
  
  
  
  					"""simple docstring"""
  
  
  
  
  
  
  
  					with self.assertRaises(SCREAMING_SNAKE_CASE							):
  							ConfigMixin.load_config("dummy_path"							)
  
  
  			def 							lowerCamelCase_				(     self							):
  
  
  
  					"""simple docstring"""
  
  
  
  
  
  
  
  					snake_case		:						Dict								=				SampleObject()
  					snake_case		:						Dict								=				obj.config
  					assert config["a"] == 2
  					assert config["b"] == 5
  					assert config["c"] == (2, 5)
  					assert config["d"] == "for diffusion"
  					assert config["e"] == [1, 3]
  
  					# init ignore private arguments
  					snake_case		:						Dict								=				SampleObject(_name_or_path="lalala"							)
  					snake_case		:						List[Any]								=				obj.config
  					assert config["a"] == 2
  					assert config["b"] == 5
  					assert config["c"] == (2, 5)
  					assert config["d"] == "for diffusion"
  					assert config["e"] == [1, 3]
  
  					# can override default
  					snake_case		:						str								=				SampleObject(c=6							)
  					snake_case		:						Any								=				obj.config
  					assert config["a"] == 2
  					assert config["b"] == 5
  					assert config["c"] == 6
  					assert config["d"] == "for diffusion"
  					assert config["e"] == [1, 3]
  
  					# can use positional arguments.
  					snake_case		:						int								=				SampleObject(1				, c=6							)
  					snake_case		:						Dict								=				obj.config
  					assert config["a"] == 1
  					assert config["b"] == 5
  					assert config["c"] == 6
  					assert config["d"] == "for diffusion"
  					assert config["e"] == [1, 3]
  
  
  			def 							lowerCamelCase_				(     self							):
  
  
  
  					"""simple docstring"""
  
  
  
  
  
  
  
  					snake_case		:						str								=				SampleObject()
  					snake_case		:						List[str]								=				obj.config
  
  					assert config["a"] == 2
  					assert config["b"] == 5
  					assert config["c"] == (2, 5)
  					assert config["d"] == "for diffusion"
  					assert config["e"] == [1, 3]
  
  					with tempfile.TemporaryDirectory() as tmpdirname:
  							obj.save_config(SCREAMING_SNAKE_CASE							)
  							snake_case		:						Union[str, Any]								=				SampleObject.from_config(SampleObject.load_config(SCREAMING_SNAKE_CASE							)							)
  							snake_case		:						Union[str, Any]								=				new_obj.config
  
  					# unfreeze configs
  					snake_case		:						List[str]								=				dict(SCREAMING_SNAKE_CASE							)
  					snake_case		:						Union[str, Any]								=				dict(SCREAMING_SNAKE_CASE							)
  
  					assert config.pop("c"							) == (2, 5)  # instantiated as tuple
  					assert new_config.pop("c"							) == [2, 5]  # saved & loaded as list because of json
  					config.pop("_use_default_values"							)
  					assert config == new_config
  
  
  			def 							lowerCamelCase_				(     self							):
  
  
  
  					"""simple docstring"""
  
  
  
  
  
  
  
  					snake_case		:						List[Any]								=				logging.get_logger("diffusers.configuration_utils"							)
  					# 30 for warning
  					logger.setLevel(30							)
  
  					with CaptureLogger(SCREAMING_SNAKE_CASE							) as cap_logger:
  							snake_case		:						Any								=				DDIMScheduler.from_pretrained(
  							    "hf-internal-testing/tiny-stable-diffusion-torch"				, subfolder="scheduler"							)
  
  					assert ddim.__class__ == DDIMScheduler
  					# no warning should be thrown
  					assert cap_logger.out == ""
  
  
  			def 							lowerCamelCase_				(     self							):
  
  
  
  					"""simple docstring"""
  
  
  
  
  
  
  
  					snake_case		:						int								=				logging.get_logger("diffusers.configuration_utils"							)
  					# 30 for warning
  					logger.setLevel(30							)
  
  					with CaptureLogger(SCREAMING_SNAKE_CASE							) as cap_logger:
  							snake_case		:						Optional[int]								=				EulerDiscreteScheduler.from_pretrained(
  							    "hf-internal-testing/tiny-stable-diffusion-torch"				, subfolder="scheduler"							)
  
  					assert euler.__class__ == EulerDiscreteScheduler
  					# no warning should be thrown
  					assert cap_logger.out == ""
  
  
  			def 							lowerCamelCase_				(     self							):
  
  
  
  					"""simple docstring"""
  
  
  
  
  
  
  
  					snake_case		:						Any								=				logging.get_logger("diffusers.configuration_utils"							)
  					# 30 for warning
  					logger.setLevel(30							)
  
  					with CaptureLogger(SCREAMING_SNAKE_CASE							) as cap_logger:
  							snake_case		:						Union[str, Any]								=				EulerAncestralDiscreteScheduler.from_pretrained(
  							    "hf-internal-testing/tiny-stable-diffusion-torch"				, subfolder="scheduler"							)
  
  					assert euler.__class__ == EulerAncestralDiscreteScheduler
  					# no warning should be thrown
  					assert cap_logger.out == ""
  
  
  			def 							lowerCamelCase_				(     self							):
  
  
  
  					"""simple docstring"""
  
  
  
  
  
  
  
  					snake_case		:						Union[str, Any]								=				logging.get_logger("diffusers.configuration_utils"							)
  					# 30 for warning
  					logger.setLevel(30							)
  
  					with CaptureLogger(SCREAMING_SNAKE_CASE							) as cap_logger:
  							snake_case		:						List[Any]								=				PNDMScheduler.from_pretrained(
  							    "hf-internal-testing/tiny-stable-diffusion-torch"				, subfolder="scheduler"							)
  
  					assert pndm.__class__ == PNDMScheduler
  					# no warning should be thrown
  					assert cap_logger.out == ""
  
  
  			def 							lowerCamelCase_				(     self							):
  
  
  
  					"""simple docstring"""
  
  
  
  
  
  
  
  					snake_case		:						str								=				logging.get_logger("diffusers.configuration_utils"							)
  					# 30 for warning
  					logger.setLevel(30							)
  
  					with CaptureLogger(SCREAMING_SNAKE_CASE							) as cap_logger:
  							snake_case		:						List[Any]								=				DDPMScheduler.from_pretrained(
  							    "hf-internal-testing/tiny-stable-diffusion-torch"				, subfolder="scheduler"				, prediction_type="sample"				, beta_end=8				, )
  
  					with CaptureLogger(SCREAMING_SNAKE_CASE							) as cap_logger_a:
  							snake_case		:						Optional[int]								=				DDPMScheduler.from_pretrained("google/ddpm-celebahq-256"				, beta_start=88							)
  
  					assert ddpm.__class__ == DDPMScheduler
  					assert ddpm.config.prediction_type == "sample"
  					assert ddpm.config.beta_end == 8
  					assert ddpm_a.config.beta_start == 88
  
  					# no warning should be thrown
  					assert cap_logger.out == ""
  					assert cap_logger_a.out == ""
  
  
  			def 							lowerCamelCase_				(     self							):
  
  
  
  					"""simple docstring"""
  
  
  
  
  
  
  
  					snake_case		:						Dict								=				logging.get_logger("diffusers.configuration_utils"							)
  					# 30 for warning
  					logger.setLevel(30							)
  
  					with CaptureLogger(SCREAMING_SNAKE_CASE							) as cap_logger:
  							snake_case		:						Union[str, Any]								=				DPMSolverMultistepScheduler.from_pretrained(
  							    "hf-internal-testing/tiny-stable-diffusion-torch"				, subfolder="scheduler"							)
  
  					assert dpm.__class__ == DPMSolverMultistepScheduler
  					# no warning should be thrown
  					assert cap_logger.out == ""
  
  
  
  			def 							lowerCamelCase_				(     self							):
  
  
  
  					"""simple docstring"""
  
  
  
  
  
  
  
  					snake_case		:						Optional[Any]								=				SampleObject()
  
  					snake_case		:						str								=				{k: v for k, v in config.config.items() if not k.startswith("_"							)}
  
  					# make sure that default config has all keys in `_use_default_values`
  					assert set(config_dict.keys()							) == set(config.config._use_default_values							)
  
  					with tempfile.TemporaryDirectory() as tmpdirname:
  							config.save_config(SCREAMING_SNAKE_CASE							)
  
  							# now loading it with SampleObject2 should put f into `_use_default_values`
  							snake_case		:						Optional[int]								=				SampleObjecta.from_config(SCREAMING_SNAKE_CASE							)
  
  							assert "f" in config._use_default_values
  							assert config.f == [1, 3]
  
  					# now loading the config, should **NOT** use [1, 3] for `f`, but the default [1, 4] value
  					# **BECAUSE** it is part of `config._use_default_values`
  					snake_case		:						Tuple								=				SampleObjecta.from_config(config.config							)
  					assert new_config.f == [5, 4]
  
  					config.config._use_default_values.pop()
  					snake_case		:						List[Any]								=				SampleObjecta.from_config(config.config							)
  					assert new_config_a.f == [1, 3]
  
  					# Nevertheless "e" should still be correctly loaded to [1, 3] from SampleObject2 instead of defaulting to [1, 5]
  					assert new_config_a.e == [1, 3]
  
  