
"""simple docstring"""







from typing import Callable, List, Optional, Union

import torch

from ...models import UNetaDModel
from ...schedulers import CMStochasticIterativeScheduler
from ...utils import (
    is_accelerate_available,
    is_accelerate_version,
    logging,
    randn_tensor,
    replace_example_docstring,
)
from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput


lowerCamelCase__     =						logging.get_logger(__name__)  # pylint: disable=invalid-name


lowerCamelCase__     =						"""
    Examples:
        ```py
        >>> import torch

        >>> from diffusers import ConsistencyModelPipeline

        >>> device = \"cuda\"
        >>> # Load the cd_imagenet64_l2 checkpoint.
        >>> model_id_or_path = \"openai/diffusers-cd_imagenet64_l2\"
        >>> pipe = ConsistencyModelPipeline.from_pretrained(model_id_or_path, torch_dtype=torch.float16)
        >>> pipe.to(device)

        >>> # Onestep Sampling
        >>> image = pipe(num_inference_steps=1).images[0]
        >>> image.save(\"cd_imagenet64_l2_onestep_sample.png\")

        >>> # Onestep sampling, class-conditional image generation
        >>> # ImageNet-64 class label 145 corresponds to king penguins
        >>> image = pipe(num_inference_steps=1, class_labels=145).images[0]
        >>> image.save(\"cd_imagenet64_l2_onestep_sample_penguin.png\")

        >>> # Multistep sampling, class-conditional image generation
        >>> # Timesteps can be explicitly specified; the particular timesteps below are from the original Github repo:
        >>> # https://github.com/openai/consistency_models/blob/main/scripts/launch.sh#L77
        >>> image = pipe(num_inference_steps=None, timesteps=[22, 0], class_labels=145).images[0]
        >>> image.save(\"cd_imagenet64_l2_multistep_sample_penguin.png\")
        ```
"""




class 					A__			(      _lowerCamelCase):

		def __init__( self			,						_SCREAMING_SNAKE_CASE			,						_SCREAMING_SNAKE_CASE					):
			super().__init__()

			self.register_modules(
			    unet=_SCREAMING_SNAKE_CASE			,						scheduler=_SCREAMING_SNAKE_CASE			,						)

			__lowerCAmelCase     :		Optional[Any]		     = None

		def 				__lowerCamelCase				( self			,						_SCREAMING_SNAKE_CASE=0					):
			if is_accelerate_available() and is_accelerate_version('>='			,						'0.14.0'					):
				from accelerate import cpu_offload
			else:
				raise ImportError('`enable_sequential_cpu_offload` requires `accelerate v0.14.0` or higher'					)

			__lowerCAmelCase     :		Tuple		     = torch.device(f"cuda:{gpu_id}"					)

			if self.device.type != "cpu":
				self.to('cpu'			,						silence_dtype_warnings=_SCREAMING_SNAKE_CASE					)
				torch.cuda.empty_cache()  # otherwise we don't see the memory savings (but they probably exist)

			for cpu_offloaded_model in [self.unet]:
				cpu_offload(_SCREAMING_SNAKE_CASE			,						_SCREAMING_SNAKE_CASE					)

			if self.safety_checker is not None:
				cpu_offload(self.safety_checker			,						execution_device=_SCREAMING_SNAKE_CASE			,						offload_buffers=_SCREAMING_SNAKE_CASE					)

		def 				__lowerCamelCase				( self			,						_SCREAMING_SNAKE_CASE=0					):
			if is_accelerate_available() and is_accelerate_version('>='			,						'0.17.0.dev0'					):
				from accelerate import cpu_offload_with_hook
			else:
				raise ImportError('`enable_model_cpu_offload` requires `accelerate v0.17.0` or higher.'					)

			__lowerCAmelCase     :		Union[str, Any]		     = torch.device(f"cuda:{gpu_id}"					)

			if self.device.type != "cpu":
				self.to('cpu'			,						silence_dtype_warnings=_SCREAMING_SNAKE_CASE					)
				torch.cuda.empty_cache()  # otherwise we don't see the memory savings (but they probably exist)

			__lowerCAmelCase     :		Dict		     = None
			for cpu_offloaded_model in [self.unet]:
				__lowerCAmelCase     ,  __lowerCAmelCase     :		Tuple		     = cpu_offload_with_hook(_SCREAMING_SNAKE_CASE			,						_SCREAMING_SNAKE_CASE			,						prev_module_hook=_SCREAMING_SNAKE_CASE					)

			if self.safety_checker is not None:
				__lowerCAmelCase     ,  __lowerCAmelCase     :		Union[str, Any]		     = cpu_offload_with_hook(self.safety_checker			,						_SCREAMING_SNAKE_CASE			,						prev_module_hook=_SCREAMING_SNAKE_CASE					)

			# We'll offload the last model manually.
			__lowerCAmelCase     :		Any		     = hook

		@property
		# Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline._execution_device
		def 				__lowerCamelCase				( self					):
			if not hasattr(self.unet			,						'_hf_hook'					):
				return self.device
			for module in self.unet.modules():
				if (
				    hasattr(_SCREAMING_SNAKE_CASE			,						'_hf_hook'					)
				    and hasattr(module._hf_hook			,						'execution_device'					)
				    and module._hf_hook.execution_device is not None
				):
					return torch.device(module._hf_hook.execution_device					)
			return self.device

		def 				__lowerCamelCase				( self			,						_SCREAMING_SNAKE_CASE			,						_SCREAMING_SNAKE_CASE			,						_SCREAMING_SNAKE_CASE			,						_SCREAMING_SNAKE_CASE			,						_SCREAMING_SNAKE_CASE			,						_SCREAMING_SNAKE_CASE			,						_SCREAMING_SNAKE_CASE			,						_SCREAMING_SNAKE_CASE=None					):
			__lowerCAmelCase     :		List[Any]		     = (batch_size, num_channels, height, width)
			if isinstance(_SCREAMING_SNAKE_CASE			,						_SCREAMING_SNAKE_CASE					) and len(_SCREAMING_SNAKE_CASE					) != batch_size:
				raise ValueError(
				    f"You have passed a list of generators of length {len(_SCREAMING_SNAKE_CASE					)}, but requested an effective batch"
				    f" size of {batch_size}. Make sure the batch size matches the length of the generators."					)

			if latents is None:
				__lowerCAmelCase     :		Any		     = randn_tensor(_SCREAMING_SNAKE_CASE			,						generator=_SCREAMING_SNAKE_CASE			,						device=_SCREAMING_SNAKE_CASE			,						dtype=_SCREAMING_SNAKE_CASE					)
			else:
				__lowerCAmelCase     :		str		     = latents.to(device=_SCREAMING_SNAKE_CASE			,						dtype=_SCREAMING_SNAKE_CASE					)

			# scale the initial noise by the standard deviation required by the scheduler
			__lowerCAmelCase     :		Any		     = latents * self.scheduler.init_noise_sigma
			return latents

		def 				__lowerCamelCase				( self			,						_SCREAMING_SNAKE_CASE			,						_SCREAMING_SNAKE_CASE = "pil"					):
			if output_type not in ["pt", "np", "pil"]:
				raise ValueError(
				    f"output_type={output_type} is not supported. Make sure to choose one of ['pt', 'np', or 'pil']"					)

			# Equivalent to diffusers.VaeImageProcessor.denormalize
			__lowerCAmelCase     :		Any		     = (sample / 2 + 0.5).clamp(0			,						1					)
			if output_type == "pt":
				return sample

			# Equivalent to diffusers.VaeImageProcessor.pt_to_numpy
			__lowerCAmelCase     :		Optional[int]		     = sample.cpu().permute(0			,						2			,						3			,						1					).numpy()
			if output_type == "np":
				return sample

			# Output_type must be 'pil'
			__lowerCAmelCase     :		List[Any]		     = self.numpy_to_pil(_SCREAMING_SNAKE_CASE					)
			return sample

		def 				__lowerCamelCase				( self			,						_SCREAMING_SNAKE_CASE			,						_SCREAMING_SNAKE_CASE			,						_SCREAMING_SNAKE_CASE=None					):
			if self.unet.config.num_class_embeds is not None:
				if isinstance(_SCREAMING_SNAKE_CASE			,						_SCREAMING_SNAKE_CASE					):
					__lowerCAmelCase     :		Optional[Any]		     = torch.tensor(_SCREAMING_SNAKE_CASE			,						dtype=torch.int					)
				elif isinstance(_SCREAMING_SNAKE_CASE			,						_SCREAMING_SNAKE_CASE					):
					assert batch_size == 1, "Batch size must be 1 if classes is an int"
					__lowerCAmelCase     :		Optional[int]		     = torch.tensor([class_labels]			,						dtype=torch.int					)
				elif class_labels is None:
					# Randomly generate batch_size class labels
					# TODO: should use generator here? int analogue of randn_tensor is not exposed in ...utils
					__lowerCAmelCase     :		str		     = torch.randint(0			,						self.unet.config.num_class_embeds			,						size=(batch_size,)					)
				__lowerCAmelCase     :		Optional[Any]		     = class_labels.to(_SCREAMING_SNAKE_CASE					)
			else:
				__lowerCAmelCase     :		Any		     = None
			return class_labels

		def 				__lowerCamelCase				( self			,						_SCREAMING_SNAKE_CASE			,						_SCREAMING_SNAKE_CASE			,						_SCREAMING_SNAKE_CASE			,						_SCREAMING_SNAKE_CASE			,						_SCREAMING_SNAKE_CASE			,						_SCREAMING_SNAKE_CASE					):
			if num_inference_steps is None and timesteps is None:
				raise ValueError('Exactly one of `num_inference_steps` or `timesteps` must be supplied.'					)

			if num_inference_steps is not None and timesteps is not None:
				logger.warning(
				    f"Both `num_inference_steps`: {num_inference_steps} and `timesteps`: {timesteps} are supplied;"
				    ' `timesteps` will be used over `num_inference_steps`.'					)

			if latents is not None:
				__lowerCAmelCase     :		List[Any]		     = (batch_size, 3, img_size, img_size)
				if latents.shape != expected_shape:
					raise ValueError(f"The shape of latents is {latents.shape} but is expected to be {expected_shape}."					)

			if (callback_steps is None) or (
			    callback_steps is not None and (not isinstance(_SCREAMING_SNAKE_CASE			,						_SCREAMING_SNAKE_CASE					) or callback_steps <= 0)
			):
				raise ValueError(
				    f"`callback_steps` has to be a positive integer but is {callback_steps} of type"
				    f" {type(_SCREAMING_SNAKE_CASE					)}."					)







		@torch.no_grad()
		@replace_example_docstring(_SCREAMING_SNAKE_CASE					)
		def __call__( self			,						_SCREAMING_SNAKE_CASE = 1			,						_SCREAMING_SNAKE_CASE = None			,						_SCREAMING_SNAKE_CASE = 1			,						_SCREAMING_SNAKE_CASE = None			,						_SCREAMING_SNAKE_CASE = None			,						_SCREAMING_SNAKE_CASE = None			,						_SCREAMING_SNAKE_CASE = "pil"			,						_SCREAMING_SNAKE_CASE = True			,						_SCREAMING_SNAKE_CASE = None			,						_SCREAMING_SNAKE_CASE = 1			,						):
			__lowerCAmelCase     :		List[Any]		     = self.unet.config.sample_size
			__lowerCAmelCase     :		Optional[Any]		     = self._execution_device

			# 1. Check inputs
			self.check_inputs(_SCREAMING_SNAKE_CASE			,						_SCREAMING_SNAKE_CASE			,						_SCREAMING_SNAKE_CASE			,						_SCREAMING_SNAKE_CASE			,						_SCREAMING_SNAKE_CASE			,						_SCREAMING_SNAKE_CASE					)

			# 2. Prepare image latents
			# Sample image latents x_0 ~ N(0, sigma_0^2 * I)
			__lowerCAmelCase     :		str		     = self.prepare_latents(
			    batch_size=_SCREAMING_SNAKE_CASE			,						num_channels=self.unet.config.in_channels			,						height=_SCREAMING_SNAKE_CASE			,						width=_SCREAMING_SNAKE_CASE			,						dtype=self.unet.dtype			,						device=_SCREAMING_SNAKE_CASE			,						generator=_SCREAMING_SNAKE_CASE			,						latents=_SCREAMING_SNAKE_CASE			,						)

			# 3. Handle class_labels for class-conditional models
			__lowerCAmelCase     :		Any		     = self.prepare_class_labels(_SCREAMING_SNAKE_CASE			,						_SCREAMING_SNAKE_CASE			,						class_labels=_SCREAMING_SNAKE_CASE					)

			# 4. Prepare timesteps
			if timesteps is not None:
				self.scheduler.set_timesteps(timesteps=_SCREAMING_SNAKE_CASE			,						device=_SCREAMING_SNAKE_CASE					)
				__lowerCAmelCase     :		Dict		     = self.scheduler.timesteps
				__lowerCAmelCase     :		Optional[int]		     = len(_SCREAMING_SNAKE_CASE					)
			else:
				self.scheduler.set_timesteps(_SCREAMING_SNAKE_CASE					)
				__lowerCAmelCase     :		str		     = self.scheduler.timesteps

			# 5. Denoising loop
			# Multistep sampling: implements Algorithm 1 in the paper
			with self.progress_bar(total=_SCREAMING_SNAKE_CASE					) as progress_bar:
				for i, t in enumerate(_SCREAMING_SNAKE_CASE					):
					__lowerCAmelCase     :		int		     = self.scheduler.scale_model_input(_SCREAMING_SNAKE_CASE			,						_SCREAMING_SNAKE_CASE					)
					__lowerCAmelCase     :		List[Any]		     = self.unet(_SCREAMING_SNAKE_CASE			,						_SCREAMING_SNAKE_CASE			,						class_labels=_SCREAMING_SNAKE_CASE			,						return_dict=_SCREAMING_SNAKE_CASE					)[0]

					__lowerCAmelCase     :		List[str]		     = self.scheduler.step(_SCREAMING_SNAKE_CASE			,						_SCREAMING_SNAKE_CASE			,						_SCREAMING_SNAKE_CASE			,						generator=_SCREAMING_SNAKE_CASE					)[0]

					# call the callback, if provided
					progress_bar.update()
					if callback is not None and i % callback_steps == 0:
						callback(_SCREAMING_SNAKE_CASE			,						_SCREAMING_SNAKE_CASE			,						_SCREAMING_SNAKE_CASE					)

        # 6. Post-process image sample
			__lowerCAmelCase     :		int		     = self.postprocess_image(_SCREAMING_SNAKE_CASE			,						output_type=_SCREAMING_SNAKE_CASE					)

			# Offload last model to CPU
			if hasattr(self			,						'final_offload_hook'					) and self.final_offload_hook is not None:
				self.final_offload_hook.offload()

			if not return_dict:
				return (image,)

			return ImagePipelineOutput(images=_SCREAMING_SNAKE_CASE					)

"""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


lowerCamelCase__     =						logging.get_logger(__name__)




class 					A__			(      _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 / 2_55			,						_SCREAMING_SNAKE_CASE = True			,						_SCREAMING_SNAKE_CASE = None			,						_SCREAMING_SNAKE_CASE = None			,						**_SCREAMING_SNAKE_CASE			,						):
			super().__init__(**_SCREAMING_SNAKE_CASE					)
			__lowerCAmelCase     :		List[str]		     = crop_size if crop_size is not None else {'height': 2_56, 'width': 2_56}
			__lowerCAmelCase     :		int		     = get_size_dict(_SCREAMING_SNAKE_CASE			,						param_name='crop_size'					)
			__lowerCAmelCase     :		List[str]		     = size if size is not None else {'height': 2_24, 'width': 2_24}
			__lowerCAmelCase     :		Optional[int]		     = get_size_dict(_SCREAMING_SNAKE_CASE					)

			__lowerCAmelCase     :		str		     = do_center_crop
			__lowerCAmelCase     :		Optional[int]		     = crop_size
			__lowerCAmelCase     :		Optional[Any]		     = do_resize
			__lowerCAmelCase     :		Optional[int]		     = size
			__lowerCAmelCase     :		List[Any]		     = resample
			__lowerCAmelCase     :		str		     = do_rescale
			__lowerCAmelCase     :		str		     = rescale_factor
			__lowerCAmelCase     :		Union[str, Any]		     = do_normalize
			__lowerCAmelCase     :		str		     = image_mean if image_mean is not None else IMAGENET_DEFAULT_MEAN
			__lowerCAmelCase     :		List[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			,						):
			__lowerCAmelCase     :		List[str]		     = self.size if size is None else size
			__lowerCAmelCase     :		List[str]		     = get_size_dict(_SCREAMING_SNAKE_CASE					)
			__lowerCAmelCase     :		Optional[Any]		     = get_size_dict(_SCREAMING_SNAKE_CASE			,						param_name='crop_size'					)

			__lowerCAmelCase     ,  __lowerCAmelCase     :		Optional[int]		     = get_image_size(_SCREAMING_SNAKE_CASE					)
			__lowerCAmelCase     :		Tuple		     = min(_SCREAMING_SNAKE_CASE			,						_SCREAMING_SNAKE_CASE					)
			__lowerCAmelCase     :		Optional[Any]		     = (size['height'] / crop_size['height']) * min_dim
			__lowerCAmelCase     :		Tuple		     = (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			,						):
			__lowerCAmelCase     :		Dict		     = 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			,						):
			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			,						):
			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			,						):
			__lowerCAmelCase     :		Tuple		     = do_center_crop if do_center_crop is not None else self.do_center_crop
			__lowerCAmelCase     :		Optional[int]		     = crop_size if crop_size is not None else self.crop_size
			__lowerCAmelCase     :		int		     = get_size_dict(_SCREAMING_SNAKE_CASE			,						param_name='crop_size'					)
			__lowerCAmelCase     :		List[str]		     = do_resize if do_resize is not None else self.do_resize
			__lowerCAmelCase     :		Any		     = size if size is not None else self.size
			__lowerCAmelCase     :		Any		     = get_size_dict(_SCREAMING_SNAKE_CASE					)
			__lowerCAmelCase     :		Any		     = resample if resample is not None else self.resample
			__lowerCAmelCase     :		Union[str, Any]		     = do_rescale if do_rescale is not None else self.do_rescale
			__lowerCAmelCase     :		int		     = rescale_factor if rescale_factor is not None else self.rescale_factor
			__lowerCAmelCase     :		List[Any]		     = do_normalize if do_normalize is not None else self.do_normalize
			__lowerCAmelCase     :		Tuple		     = image_mean if image_mean is not None else self.image_mean
			__lowerCAmelCase     :		Union[str, Any]		     = image_std if image_std is not None else self.image_std

			__lowerCAmelCase     :		Tuple		     = 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.
			__lowerCAmelCase     :		int		     = [to_numpy_array(_SCREAMING_SNAKE_CASE					) for image in images]

			if do_center_crop:
				__lowerCAmelCase     :		int		     = [self.center_crop(_SCREAMING_SNAKE_CASE			,						_SCREAMING_SNAKE_CASE			,						size=_SCREAMING_SNAKE_CASE					) for image in images]

			if do_resize:
				__lowerCAmelCase     :		Optional[Any]		     = [self.resize(image=_SCREAMING_SNAKE_CASE			,						size=_SCREAMING_SNAKE_CASE			,						resample=_SCREAMING_SNAKE_CASE					) for image in images]

			if do_rescale:
				__lowerCAmelCase     :		str		     = [self.rescale(image=_SCREAMING_SNAKE_CASE			,						scale=_SCREAMING_SNAKE_CASE					) for image in images]

			if do_normalize:
				__lowerCAmelCase     :		Optional[int]		     = [self.normalize(image=_SCREAMING_SNAKE_CASE			,						mean=_SCREAMING_SNAKE_CASE			,						std=_SCREAMING_SNAKE_CASE					) for image in images]

			__lowerCAmelCase     :		Tuple		     = [to_channel_dimension_format(_SCREAMING_SNAKE_CASE			,						_SCREAMING_SNAKE_CASE					) for image in images]

			__lowerCAmelCase     :		str		     = {'pixel_values': images}
			return BatchFeature(data=_SCREAMING_SNAKE_CASE			,						tensor_type=_SCREAMING_SNAKE_CASE					)