



'''simple docstring'''







import math
from dataclasses import dataclass
from typing import List, Optional, Tuple, Union

import numpy as np
import torch

from ..configuration_utils import ConfigMixin, register_to_config
from ..utils import BaseOutput, logging, randn_tensor
from .scheduling_utils import KarrasDiffusionSchedulers, SchedulerMixin


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




@dataclass
# Copied from diffusers.schedulers.scheduling_ddpm.DDPMSchedulerOutput with DDPM->EulerDiscrete
class 				__lowerCAmelCase(							a__      ):
			__snake_case  :		int		=      4_2
			__snake_case  :		Dict		=      None







def  SCREAMING_SNAKE_CASE__ (				SCREAMING_SNAKE_CASE ,		SCREAMING_SNAKE_CASE=0.9_9_9 ,		SCREAMING_SNAKE_CASE="cosine" ,		):
		if alpha_transform_type == "cosine":

				def alpha_bar_fn(SCREAMING_SNAKE_CASE     ):
						return math.cos((t + 0.0_0_8) / 1.0_0_8 * math.pi / 2     ) ** 2

		elif alpha_transform_type == "exp":

				def alpha_bar_fn(SCREAMING_SNAKE_CASE     ):
						return math.exp(t * -1_2.0     )

		else:
				raise ValueError(F'Unsupported alpha_tranform_type: {alpha_transform_type}'     )

		SCREAMING_SNAKE_CASE_						:str										=      []
		for i in range(lowerCamelCase__     ):
				SCREAMING_SNAKE_CASE_						:List[str]										=      i / num_diffusion_timesteps
				SCREAMING_SNAKE_CASE_						:Union[str, Any]										=      (i + 1) / num_diffusion_timesteps
				betas.append(min(1 - alpha_bar_fn(lowerCamelCase__     ) / alpha_bar_fn(lowerCamelCase__     ) ,		lowerCamelCase__     )     )
		return torch.tensor(lowerCamelCase__ ,		dtype=torch.floataa     )





class 				__lowerCAmelCase(							a__		,			a__      ):
			__snake_case  :		Any		=      [e.name for e in KarrasDiffusionSchedulers]
			__snake_case  :		Any		=      1






			@register_to_config
			def __init__(   self  :							Any      ,       SCREAMING_SNAKE_CASE  :							int = 1_000      ,       SCREAMING_SNAKE_CASE  :							float = 0.00_01      ,       SCREAMING_SNAKE_CASE  :							float = 0.02      ,       SCREAMING_SNAKE_CASE  :							str = "linear"      ,       SCREAMING_SNAKE_CASE  :							Optional[Union[np.ndarray, List[float]]] = None      ,       SCREAMING_SNAKE_CASE  :							str = "epsilon"      ,       SCREAMING_SNAKE_CASE  :							str = "linear"      ,       SCREAMING_SNAKE_CASE  :							Optional[bool] = False      ,       SCREAMING_SNAKE_CASE  :							str = "linspace"      ,       SCREAMING_SNAKE_CASE  :							int = 0      ,       ):




					"""simple docstring"""







					if trained_betas is not None:
							SCREAMING_SNAKE_CASE_						:List[Any]										=      torch.tensor(_lowerCamelCase      ,       dtype=torch.floataa	)
					elif beta_schedule == "linear":
							SCREAMING_SNAKE_CASE_						:List[str]										=      torch.linspace(_lowerCamelCase      ,       _lowerCamelCase      ,       _lowerCamelCase      ,       dtype=torch.floataa	)
					elif beta_schedule == "scaled_linear":
							# this schedule is very specific to the latent diffusion model.
							SCREAMING_SNAKE_CASE_						:int										=      (
							    torch.linspace(beta_start**0.5      ,       beta_end**0.5      ,       _lowerCamelCase      ,       dtype=torch.floataa	) ** 2
							)
					elif beta_schedule == "squaredcos_cap_v2":
							# Glide cosine schedule
							SCREAMING_SNAKE_CASE_						:Tuple										=      betas_for_alpha_bar(_lowerCamelCase	)
					else:
							raise NotImplementedError(f'{beta_schedule} does is not implemented for {self.__class__}'	)

					SCREAMING_SNAKE_CASE_						:Dict										=      1.0 - self.betas
					SCREAMING_SNAKE_CASE_						:Dict										=      torch.cumprod(self.alphas      ,       dim=0	)

					SCREAMING_SNAKE_CASE_						:Optional[int]										=      np.array(((1 - self.alphas_cumprod) / self.alphas_cumprod) ** 0.5	)
					SCREAMING_SNAKE_CASE_						:List[Any]										=      np.concatenate([sigmas[::-1], [0.0]]	).astype(np.floataa	)
					SCREAMING_SNAKE_CASE_						:Dict										=      torch.from_numpy(_lowerCamelCase	)

					# setable values
					SCREAMING_SNAKE_CASE_						:Union[str, Any]										=      None
					SCREAMING_SNAKE_CASE_						:Tuple										=      np.linspace(0      ,       num_train_timesteps - 1      ,       _lowerCamelCase      ,       dtype=_lowerCamelCase	)[::-1].copy()
					SCREAMING_SNAKE_CASE_						:List[Any]										=      torch.from_numpy(_lowerCamelCase	)
					SCREAMING_SNAKE_CASE_						:List[Any]										=      False
					SCREAMING_SNAKE_CASE_						:Any										=      use_karras_sigmas






			@property
			def 				_lowercase	(   self  :							List[str]	):




					"""simple docstring"""







					if self.config.timestep_spacing in ["linspace", "trailing"]:
							return self.sigmas.max()

					return (self.sigmas.max() ** 2 + 1) ** 0.5






			def 				_lowercase	(   self  :							Any      ,       SCREAMING_SNAKE_CASE  :							torch.FloatTensor      ,       SCREAMING_SNAKE_CASE  :							Union[float, torch.FloatTensor]	):




					"""simple docstring"""







					if isinstance(_lowerCamelCase      ,       torch.Tensor	):
							SCREAMING_SNAKE_CASE_						:List[Any]										=      timestep.to(self.timesteps.device	)
					SCREAMING_SNAKE_CASE_						:Any										=      (self.timesteps == timestep).nonzero().item()
					SCREAMING_SNAKE_CASE_						:Tuple										=      self.sigmas[step_index]

					SCREAMING_SNAKE_CASE_						:Dict										=      sample / ((sigma**2 + 1) ** 0.5)

					SCREAMING_SNAKE_CASE_						:Tuple										=      True
					return sample






			def 				_lowercase	(   self  :							int      ,       SCREAMING_SNAKE_CASE  :							int      ,       SCREAMING_SNAKE_CASE  :							Union[str, torch.device] = None	):




					"""simple docstring"""







					SCREAMING_SNAKE_CASE_						:int										=      num_inference_steps

					# "linspace", "leading", "trailing" corresponds to annotation of Table 2. of https://arxiv.org/abs/2305.08891
					if self.config.timestep_spacing == "linspace":
							SCREAMING_SNAKE_CASE_						:str										=      np.linspace(0      ,       self.config.num_train_timesteps - 1      ,       _lowerCamelCase      ,       dtype=_lowerCamelCase	)[
							    ::-1
							].copy()
					elif self.config.timestep_spacing == "leading":
							SCREAMING_SNAKE_CASE_						:Union[str, Any]										=      self.config.num_train_timesteps // self.num_inference_steps
							# creates integer timesteps by multiplying by ratio
							# casting to int to avoid issues when num_inference_step is power of 3
							SCREAMING_SNAKE_CASE_						:Dict										=      (np.arange(0      ,       _lowerCamelCase	) * step_ratio).round()[::-1].copy().astype(_lowerCamelCase	)
							timesteps += self.config.steps_offset
					elif self.config.timestep_spacing == "trailing":
							SCREAMING_SNAKE_CASE_						:Tuple										=      self.config.num_train_timesteps / self.num_inference_steps
							# creates integer timesteps by multiplying by ratio
							# casting to int to avoid issues when num_inference_step is power of 3
							SCREAMING_SNAKE_CASE_						:Any										=      (np.arange(self.config.num_train_timesteps      ,       0      ,       -step_ratio	)).round().copy().astype(_lowerCamelCase	)
							timesteps -= 1
					else:
							raise ValueError(
							    f'{self.config.timestep_spacing} is not supported. Please make sure to choose one of \'linspace\', \'leading\' or \'trailing\'.'	)

					SCREAMING_SNAKE_CASE_						:Optional[int]										=      np.array(((1 - self.alphas_cumprod) / self.alphas_cumprod) ** 0.5	)
					SCREAMING_SNAKE_CASE_						:str										=      np.log(_lowerCamelCase	)

					if self.config.interpolation_type == "linear":
							SCREAMING_SNAKE_CASE_						:Tuple										=      np.interp(_lowerCamelCase      ,       np.arange(0      ,       len(_lowerCamelCase	)	)      ,       _lowerCamelCase	)
					elif self.config.interpolation_type == "log_linear":
							SCREAMING_SNAKE_CASE_						:Optional[Any]										=      torch.linspace(np.log(sigmas[-1]	)      ,       np.log(sigmas[0]	)      ,       num_inference_steps + 1	).exp()
					else:
							raise ValueError(
							    f'{self.config.interpolation_type} is not implemented. Please specify interpolation_type to either'
							    ' \'linear\' or \'log_linear\''	)

					if self.use_karras_sigmas:
							SCREAMING_SNAKE_CASE_						:List[str]										=      self._convert_to_karras(in_sigmas=_lowerCamelCase      ,       num_inference_steps=self.num_inference_steps	)
							SCREAMING_SNAKE_CASE_						:Optional[int]										=      np.array([self._sigma_to_t(_lowerCamelCase      ,       _lowerCamelCase	) for sigma in sigmas]	)

					SCREAMING_SNAKE_CASE_						:List[Any]										=      np.concatenate([sigmas, [0.0]]	).astype(np.floataa	)
					SCREAMING_SNAKE_CASE_						:List[Any]										=      torch.from_numpy(_lowerCamelCase	).to(device=_lowerCamelCase	)
					if str(_lowerCamelCase	).startswith('mps'	):
							# mps does not support float64
							SCREAMING_SNAKE_CASE_						:List[str]										=      torch.from_numpy(_lowerCamelCase	).to(_lowerCamelCase      ,       dtype=torch.floataa	)
					else:
							SCREAMING_SNAKE_CASE_						:Any										=      torch.from_numpy(_lowerCamelCase	).to(device=_lowerCamelCase	)






			def 				_lowercase	(   self  :							int      ,       SCREAMING_SNAKE_CASE  :							Union[str, Any]      ,       SCREAMING_SNAKE_CASE  :							Optional[int]	):




					"""simple docstring"""







					SCREAMING_SNAKE_CASE_						:str										=      np.log(_lowerCamelCase	)

					# get distribution
					SCREAMING_SNAKE_CASE_						:List[str]										=      log_sigma - log_sigmas[:, np.newaxis]

					# get sigmas range
					SCREAMING_SNAKE_CASE_						:Optional[int]										=      np.cumsum((dists >= 0)      ,       axis=0	).argmax(axis=0	).clip(max=log_sigmas.shape[0] - 2	)
					SCREAMING_SNAKE_CASE_						:List[str]										=      low_idx + 1

					SCREAMING_SNAKE_CASE_						:Union[str, Any]										=      log_sigmas[low_idx]
					SCREAMING_SNAKE_CASE_						:Dict										=      log_sigmas[high_idx]

					# interpolate sigmas
					SCREAMING_SNAKE_CASE_						:Tuple										=      (low - log_sigma) / (low - high)
					SCREAMING_SNAKE_CASE_						:List[Any]										=      np.clip(_lowerCamelCase      ,       0      ,       1	)

					# transform interpolation to time range
					SCREAMING_SNAKE_CASE_						:str										=      (1 - w) * low_idx + w * high_idx
					SCREAMING_SNAKE_CASE_						:Optional[int]										=      t.reshape(sigma.shape	)
					return t






			def 				_lowercase	(   self  :							Dict      ,       SCREAMING_SNAKE_CASE  :							torch.FloatTensor      ,       SCREAMING_SNAKE_CASE  :							Optional[Any]	):




					"""simple docstring"""







					SCREAMING_SNAKE_CASE_						:float										=      in_sigmas[-1].item()
					SCREAMING_SNAKE_CASE_						:float										=      in_sigmas[0].item()

					SCREAMING_SNAKE_CASE_						:str										=      7.0  # 7.0 is the value used in the paper
					SCREAMING_SNAKE_CASE_						:Optional[int]										=      np.linspace(0      ,       1      ,       _lowerCamelCase	)
					SCREAMING_SNAKE_CASE_						:str										=      sigma_min ** (1 / rho)
					SCREAMING_SNAKE_CASE_						:int										=      sigma_max ** (1 / rho)
					SCREAMING_SNAKE_CASE_						:Tuple										=      (max_inv_rho + ramp * (min_inv_rho - max_inv_rho)) ** rho
					return sigmas






			def 				_lowercase	(   self  :							List[str]      ,       SCREAMING_SNAKE_CASE  :							torch.FloatTensor      ,       SCREAMING_SNAKE_CASE  :							Union[float, torch.FloatTensor]      ,       SCREAMING_SNAKE_CASE  :							torch.FloatTensor      ,       SCREAMING_SNAKE_CASE  :							float = 0.0      ,       SCREAMING_SNAKE_CASE  :							float = 0.0      ,       SCREAMING_SNAKE_CASE  :							float = float('inf'	)      ,       SCREAMING_SNAKE_CASE  :							float = 1.0      ,       SCREAMING_SNAKE_CASE  :							Optional[torch.Generator] = None      ,       SCREAMING_SNAKE_CASE  :							bool = True      ,       ):




					"""simple docstring"""







					if (
					    isinstance(_lowerCamelCase      ,       _lowerCamelCase	)
					    or isinstance(_lowerCamelCase      ,       torch.IntTensor	)
					    or isinstance(_lowerCamelCase      ,       torch.LongTensor	)
					):
							raise ValueError(
							    (
							        'Passing integer indices (e.g. from `enumerate(timesteps)`) as timesteps to'
							        ' `EulerDiscreteScheduler.step()` is not supported. Make sure to pass'
							        ' one of the `scheduler.timesteps` as a timestep.'
							    )      ,       )

					if not self.is_scale_input_called:
							logger.warning(
							    'The `scale_model_input` function should be called before `step` to ensure correct denoising. '
							    'See `StableDiffusionPipeline` for a usage example.'	)

					if isinstance(_lowerCamelCase      ,       torch.Tensor	):
							SCREAMING_SNAKE_CASE_						:Any										=      timestep.to(self.timesteps.device	)

					SCREAMING_SNAKE_CASE_						:Tuple										=      (self.timesteps == timestep).nonzero().item()
					SCREAMING_SNAKE_CASE_						:List[Any]										=      self.sigmas[step_index]

					SCREAMING_SNAKE_CASE_						:Tuple										=      min(s_churn / (len(self.sigmas	) - 1)      ,       2**0.5 - 1	) if s_tmin <= sigma <= s_tmax else 0.0

					SCREAMING_SNAKE_CASE_						:Optional[int]										=      randn_tensor(
					    model_output.shape      ,       dtype=model_output.dtype      ,       device=model_output.device      ,       generator=_lowerCamelCase	)

					SCREAMING_SNAKE_CASE_						:List[str]										=      noise * s_noise
					SCREAMING_SNAKE_CASE_						:Optional[int]										=      sigma * (gamma + 1)

					if gamma > 0:
							SCREAMING_SNAKE_CASE_						:int										=      sample + eps * (sigma_hat**2 - sigma**2) ** 0.5

					# 1. compute predicted original sample (x_0) from sigma-scaled predicted noise
					# NOTE: "original_sample" should not be an expected prediction_type but is left in for
					# backwards compatibility
					if self.config.prediction_type == "original_sample" or self.config.prediction_type == "sample":
							SCREAMING_SNAKE_CASE_						:Optional[int]										=      model_output
					elif self.config.prediction_type == "epsilon":
							SCREAMING_SNAKE_CASE_						:List[str]										=      sample - sigma_hat * model_output
					elif self.config.prediction_type == "v_prediction":
							# * c_out + input * c_skip
							SCREAMING_SNAKE_CASE_						:Any										=      model_output * (-sigma / (sigma**2 + 1) ** 0.5) + (sample / (sigma**2 + 1))
					else:
							raise ValueError(
							    f'prediction_type given as {self.config.prediction_type} must be one of `epsilon`, or `v_prediction`'	)

					# 2. Convert to an ODE derivative
					SCREAMING_SNAKE_CASE_						:Dict										=      (sample - pred_original_sample) / sigma_hat

					SCREAMING_SNAKE_CASE_						:List[Any]										=      self.sigmas[step_index + 1] - sigma_hat

					SCREAMING_SNAKE_CASE_						:Union[str, Any]										=      sample + derivative * dt

					if not return_dict:
							return (prev_sample,)

					return EulerDiscreteSchedulerOutput(prev_sample=_lowerCamelCase      ,       pred_original_sample=_lowerCamelCase	)






			def 				_lowercase	(   self  :							Dict      ,       SCREAMING_SNAKE_CASE  :							torch.FloatTensor      ,       SCREAMING_SNAKE_CASE  :							torch.FloatTensor      ,       SCREAMING_SNAKE_CASE  :							torch.FloatTensor      ,       ):




					"""simple docstring"""







					SCREAMING_SNAKE_CASE_						:Union[str, Any]										=      self.sigmas.to(device=original_samples.device      ,       dtype=original_samples.dtype	)
					if original_samples.device.type == "mps" and torch.is_floating_point(_lowerCamelCase	):
							# mps does not support float64
							SCREAMING_SNAKE_CASE_						:Optional[int]										=      self.timesteps.to(original_samples.device      ,       dtype=torch.floataa	)
							SCREAMING_SNAKE_CASE_						:Optional[Any]										=      timesteps.to(original_samples.device      ,       dtype=torch.floataa	)
					else:
							SCREAMING_SNAKE_CASE_						:int										=      self.timesteps.to(original_samples.device	)
							SCREAMING_SNAKE_CASE_						:str										=      timesteps.to(original_samples.device	)

					SCREAMING_SNAKE_CASE_						:Any										=      [(schedule_timesteps == t).nonzero().item() for t in timesteps]

					SCREAMING_SNAKE_CASE_						:Tuple										=      sigmas[step_indices].flatten()
					while len(sigma.shape	) < len(original_samples.shape	):
							SCREAMING_SNAKE_CASE_						:Union[str, Any]										=      sigma.unsqueeze(-1	)

					SCREAMING_SNAKE_CASE_						:int										=      original_samples + noise * sigma
					return noisy_samples






			def __len__(   self  :							List[Any]	):




					"""simple docstring"""







					return self.config.num_train_timesteps






'''simple docstring'''




import unittest

import numpy as np

from transformers.testing_utils import require_torch, require_vision
from transformers.utils import is_torch_available, is_vision_available

from ...test_image_processing_common import ImageProcessingSavingTestMixin


if is_torch_available():
							import torch

if is_vision_available():
							from PIL import Image

							from transformers import SwinaSRImageProcessor
							from transformers.image_transforms import get_image_size






class      UpperCamelCase_  (unittest.TestCase  ):







						"""simple docstring"""


						def __init__(  self   :							Tuple				,			_lowerCamelCase   :							str				,			_lowerCamelCase   :							str=7				,			_lowerCamelCase   :							Tuple=3				,			_lowerCamelCase   :							Any=18				,			_lowerCamelCase   :							Optional[int]=30				,			_lowerCamelCase   :							List[Any]=400				,			_lowerCamelCase   :							int=True				,			_lowerCamelCase   :							Dict=1 / 255				,			_lowerCamelCase   :							List[str]=True				,			_lowerCamelCase   :							Optional[int]=8				,			):





											"""simple docstring"""







											A_			:  Tuple			=				parent
											A_			:  str			=				batch_size
											A_			:  Optional[Any]			=				num_channels
											A_			:  Union[str, Any]			=				image_size
											A_			:  Optional[int]			=				min_resolution
											A_			:  List[Any]			=				max_resolution
											A_			:  int			=				do_rescale
											A_			:  Optional[Any]			=				rescale_factor
											A_			:  Any			=				do_pad
											A_			:  Tuple			=				pad_size







						def    _a     (  self   :							List[Any]     ):





											"""simple docstring"""







											return {
											    "do_rescale": self.do_rescale,
											    "rescale_factor": self.rescale_factor,
											    "do_pad": self.do_pad,
											    "pad_size": self.pad_size,
											}







						def    _a     (  self   :							Tuple				,			_lowerCamelCase   :							List[str]=False				,			_lowerCamelCase   :							Tuple=False				,			_lowerCamelCase   :							str=False     ):





											"""simple docstring"""







											assert not (numpify and torchify), "You cannot specify both numpy and PyTorch tensors at the same time"

											if equal_resolution:
																A_			:  List[Any]			=				[]
																for i in range(self.batch_size     ):
																					image_inputs.append(
																					    np.random.randint(
																					        255				,			size=(self.num_channels, self.max_resolution, self.max_resolution)				,			dtype=np.uinta     )     )
											else:
																A_			:  List[Any]			=				[]
																for i in range(self.batch_size     ):
																					A_			,A_			:  List[str]			=				np.random.choice(np.arange(self.min_resolution				,			self.max_resolution     )				,			2     )
																					image_inputs.append(np.random.randint(255				,			size=(self.num_channels, width, height)				,			dtype=np.uinta     )     )

											if not numpify and not torchify:
																# PIL expects the channel dimension as last dimension
																A_			:  Any			=				[Image.fromarray(np.moveaxis(_lowerCamelCase				,			0				,			-1     )     ) for x in image_inputs]

											if torchify:
																A_			:  str			=				[torch.from_numpy(_lowerCamelCase     ) for x in image_inputs]

											return image_inputs






@require_torch
@require_vision
class      UpperCamelCase_  (a__,   unittest.TestCase  ):







						"""simple docstring"""


						_lowerCAmelCase         =       SwinaSRImageProcessor if is_vision_available() else None







						def    _a     (  self   :							List[str]     ):





											"""simple docstring"""







											A_			:  int			=				SwinaSRImageProcessingTester(self     )







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





											"""simple docstring"""







											return self.image_processor_tester.prepare_image_processor_dict()







						def    _a     (  self   :							Any     ):





											"""simple docstring"""







											A_			:  Optional[int]			=				self.image_processing_class(**self.image_processor_dict     )
											self.assertTrue(hasattr(_lowerCamelCase				,			'''do_rescale'''     )     )
											self.assertTrue(hasattr(_lowerCamelCase				,			'''rescale_factor'''     )     )
											self.assertTrue(hasattr(_lowerCamelCase				,			'''do_pad'''     )     )
											self.assertTrue(hasattr(_lowerCamelCase				,			'''pad_size'''     )     )







						def    _a     (  self   :							Tuple     ):





											"""simple docstring"""







											pass







						def    _a     (  self   :							Optional[int]				,			_lowerCamelCase   :							Optional[int]     ):





											"""simple docstring"""







											A_			,A_			:  Any			=				get_image_size(_lowerCamelCase     )
											A_			:  List[Any]			=				self.image_processor_tester.pad_size

											A_			:  Dict			=				(old_height // size + 1) * size - old_height
											A_			:  Optional[Any]			=				(old_width // size + 1) * size - old_width
											return old_height + pad_height, old_width + pad_width







						def    _a     (  self   :							int     ):





											"""simple docstring"""







											A_			:  Dict			=				self.image_processing_class(**self.image_processor_dict     )
											# create random PIL images
											A_			:  Optional[int]			=				self.image_processor_tester.prepare_inputs(equal_resolution=_lowerCamelCase     )
											for image in image_inputs:
																self.assertIsInstance(_lowerCamelCase				,			Image.Image     )

											# Test not batched input
											A_			:  Any			=				image_processor(image_inputs[0]				,			return_tensors='''pt'''     ).pixel_values
											A_			,A_			:  List[Any]			=				self.calculate_expected_size(np.array(image_inputs[0]     )     )
											self.assertEqual(
											    encoded_images.shape				,			(
											        1,
											        self.image_processor_tester.num_channels,
											        expected_height,
											        expected_width,
											    )				,			)







						def    _a     (  self   :							Optional[Any]     ):





											"""simple docstring"""







											A_			:  Optional[Any]			=				self.image_processing_class(**self.image_processor_dict     )
											# create random numpy tensors
											A_			:  Dict			=				self.image_processor_tester.prepare_inputs(equal_resolution=_lowerCamelCase				,			numpify=_lowerCamelCase     )
											for image in image_inputs:
																self.assertIsInstance(_lowerCamelCase				,			np.ndarray     )

											# Test not batched input
											A_			:  Union[str, Any]			=				image_processor(image_inputs[0]				,			return_tensors='''pt'''     ).pixel_values
											A_			,A_			:  Union[str, Any]			=				self.calculate_expected_size(image_inputs[0]     )
											self.assertEqual(
											    encoded_images.shape				,			(
											        1,
											        self.image_processor_tester.num_channels,
											        expected_height,
											        expected_width,
											    )				,			)







						def    _a     (  self   :							int     ):





											"""simple docstring"""







											A_			:  Union[str, Any]			=				self.image_processing_class(**self.image_processor_dict     )
											# create random PyTorch tensors
											A_			:  List[Any]			=				self.image_processor_tester.prepare_inputs(equal_resolution=_lowerCamelCase				,			torchify=_lowerCamelCase     )
											for image in image_inputs:
																self.assertIsInstance(_lowerCamelCase				,			torch.Tensor     )

											# Test not batched input
											A_			:  int			=				image_processor(image_inputs[0]				,			return_tensors='''pt'''     ).pixel_values
											A_			,A_			:  str			=				self.calculate_expected_size(image_inputs[0]     )
											self.assertEqual(
											    encoded_images.shape				,			(
											        1,
											        self.image_processor_tester.num_channels,
											        expected_height,
											        expected_width,
											    )				,			)



