



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_STANDARD_MEAN,
    IMAGENET_STANDARD_STD,
    ChannelDimension,
    ImageInput,
    PILImageResampling,
    make_list_of_images,
    to_numpy_array,
    valid_images,
)
from ...utils import TensorType, is_vision_available, logging


if is_vision_available():
							import PIL


UpperCamelCase_	       =   logging.get_logger(__name__)







class 							a_  (		_snake_case				):
						UpperCamelCase__      :						Optional[int]				       =["pixel_values"]

						def __init__(    self	:Tuple   ,						_lowercase	:bool = True   ,						_lowercase	:Dict[str, int] = None   ,						_lowercase	:PILImageResampling = PIL.Image.NEAREST   ,						_lowercase	:bool = False   ,						_lowercase	:Dict[str, int] = None   ,						_lowercase	:Union[int, float] = 1 / 255   ,						_lowercase	:bool = False   ,						_lowercase	:bool = True   ,						_lowercase	:bool = True   ,						_lowercase	:Optional[Union[float, List[float]]] = None   ,						_lowercase	:Optional[Union[float, List[float]]] = None   ,						_lowercase	:bool = True   ,						**_lowercase	:str   ,						)		->					None:
												super().__init__(**_lowercase)
												UpperCAmelCase_     							=     size if size is not None else {'''height''': 346, '''width''': 346}
												UpperCAmelCase_     							=     get_size_dict(_lowercase)
												UpperCAmelCase_     							=     crop_size if crop_size is not None else {'''height''': 289, '''width''': 289}
												UpperCAmelCase_     							=     get_size_dict(_lowercase   ,						param_name='''crop_size''')

												UpperCAmelCase_     							=     do_resize
												UpperCAmelCase_     							=     size
												UpperCAmelCase_     							=     resample
												UpperCAmelCase_     							=     do_center_crop
												UpperCAmelCase_     							=     crop_size
												UpperCAmelCase_     							=     do_rescale
												UpperCAmelCase_     							=     rescale_factor
												UpperCAmelCase_     							=     rescale_offset
												UpperCAmelCase_     							=     do_normalize
												UpperCAmelCase_     							=     image_mean if image_mean is not None else IMAGENET_STANDARD_MEAN
												UpperCAmelCase_     							=     image_std if image_std is not None else IMAGENET_STANDARD_STD
												UpperCAmelCase_     							=     include_top

						def 	__a       (    self	:Optional[Any]   ,						_lowercase	:np.ndarray   ,						_lowercase	:Dict[str, int]   ,						_lowercase	:PILImageResampling = PIL.Image.NEAREST   ,						_lowercase	:Optional[Union[str, ChannelDimension]] = None   ,						**_lowercase	:Optional[int]   ,						)		->					np.ndarray:
												UpperCAmelCase_     							=     get_size_dict(_lowercase)
												if "height" not in size or "width" not in size:
																		raise ValueError(f"The size dictionary must have keys 'height' and 'width'. Got {size.keys()}")
												return resize(
												    _lowercase   ,						size=(size['''height'''], size['''width'''])   ,						resample=_lowercase   ,						data_format=_lowercase   ,						**_lowercase)

						def 	__a       (    self	:List[Any]   ,						_lowercase	:np.ndarray   ,						_lowercase	:Dict[str, int]   ,						_lowercase	:Optional[Union[str, ChannelDimension]] = None   ,						**_lowercase	:Dict   ,						)		->					np.ndarray:
												UpperCAmelCase_     							=     get_size_dict(_lowercase)
												if "height" not in size or "width" not in size:
																		raise ValueError(f"The size dictionary must have keys 'height' and 'width'. Got {size.keys()}")
												return center_crop(_lowercase   ,						size=(size['''height'''], size['''width'''])   ,						data_format=_lowercase   ,						**_lowercase)

						def 	__a       (    self	:Union[str, Any]   ,						_lowercase	:np.ndarray   ,						_lowercase	:Union[int, float]   ,						_lowercase	:bool = True   ,						_lowercase	:Optional[Union[str, ChannelDimension]] = None   ,						**_lowercase	:Tuple   ,						)		->					int:
												if offset:
																		UpperCAmelCase_     							=     (image - 127.5) * scale
																		if data_format is not None:
																								UpperCAmelCase_     							=     to_channel_dimension_format(_lowercase   ,						_lowercase)
																		UpperCAmelCase_     							=     rescaled_image.astype(np.floataa)
												else:
																		UpperCAmelCase_     							=     rescale(_lowercase   ,						scale=_lowercase   ,						data_format=_lowercase   ,						**_lowercase)
												return rescaled_image

						def 	__a       (    self	:str   ,						_lowercase	:np.ndarray   ,						_lowercase	:Union[float, List[float]]   ,						_lowercase	:Union[float, List[float]]   ,						_lowercase	:Optional[Union[str, ChannelDimension]] = None   ,						**_lowercase	:Union[str, Any]   ,						)		->					np.ndarray:
												return normalize(_lowercase   ,						mean=_lowercase   ,						std=_lowercase   ,						data_format=_lowercase   ,						**_lowercase)




						def 	__a       (    self	:str   ,						_lowercase	:ImageInput   ,						_lowercase	:bool = None   ,						_lowercase	:Dict[str, int] = None   ,						_lowercase	:List[Any]=None   ,						_lowercase	:bool = None   ,						_lowercase	:Dict[str, int] = None   ,						_lowercase	:bool = None   ,						_lowercase	:float = None   ,						_lowercase	:bool = None   ,						_lowercase	:bool = None   ,						_lowercase	:Optional[Union[float, List[float]]] = None   ,						_lowercase	:Optional[Union[float, List[float]]] = None   ,						_lowercase	:bool = None   ,						_lowercase	:Optional[Union[str, TensorType]] = None   ,						_lowercase	:ChannelDimension = ChannelDimension.FIRST   ,						**_lowercase	:str   ,						)		->					PIL.Image.Image:
												UpperCAmelCase_     							=     do_resize if do_resize is not None else self.do_resize
												UpperCAmelCase_     							=     resample if resample is not None else self.resample
												UpperCAmelCase_     							=     do_center_crop if do_center_crop is not None else self.do_center_crop
												UpperCAmelCase_     							=     do_rescale if do_rescale is not None else self.do_rescale
												UpperCAmelCase_     							=     rescale_factor if rescale_factor is not None else self.rescale_factor
												UpperCAmelCase_     							=     rescale_offset if rescale_offset is not None else self.rescale_offset
												UpperCAmelCase_     							=     do_normalize if do_normalize is not None else self.do_normalize
												UpperCAmelCase_     							=     image_mean if image_mean is not None else self.image_mean
												UpperCAmelCase_     							=     image_std if image_std is not None else self.image_std
												UpperCAmelCase_     							=     include_top if include_top is not None else self.include_top

												UpperCAmelCase_     							=     size if size is not None else self.size
												UpperCAmelCase_     							=     get_size_dict(_lowercase)
												UpperCAmelCase_     							=     crop_size if crop_size is not None else self.crop_size
												UpperCAmelCase_     							=     get_size_dict(_lowercase   ,						param_name='''crop_size''')

												UpperCAmelCase_     							=     make_list_of_images(_lowercase)

												if not valid_images(_lowercase):
																		raise ValueError(
																		    '''Invalid image type. Must be of type PIL.Image.Image, numpy.ndarray, '''
																		    '''torch.Tensor, tf.Tensor or jax.ndarray.''')

												if do_resize and size is None or resample is None:
																		raise ValueError('''Size and resample must be specified if do_resize is True.''')

												if do_center_crop and crop_size is None:
																		raise ValueError('''Crop size must be specified if do_center_crop 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 std must be specified if do_normalize is True.''')

												# All transformations expect numpy arrays.
												UpperCAmelCase_     							=     [to_numpy_array(_lowercase) for image in images]

												if do_resize:
																		UpperCAmelCase_     							=     [self.resize(image=_lowercase   ,						size=_lowercase   ,						resample=_lowercase) for image in images]

												if do_center_crop:
																		UpperCAmelCase_     							=     [self.center_crop(image=_lowercase   ,						size=_lowercase) for image in images]

												if do_rescale:
																		UpperCAmelCase_     							=     [self.rescale(image=_lowercase   ,						scale=_lowercase   ,						offset=_lowercase) for image in images]

												if do_normalize:
																		UpperCAmelCase_     							=     [self.normalize(image=_lowercase   ,						mean=_lowercase   ,						std=_lowercase) for image in images]

												if include_top:
																		UpperCAmelCase_     							=     [self.normalize(image=_lowercase   ,						mean=[0, 0, 0]   ,						std=_lowercase) for image in images]

												UpperCAmelCase_     							=     [to_channel_dimension_format(_lowercase   ,						_lowercase) for image in images]

												UpperCAmelCase_     							=     {'''pixel_values''': images}
												return BatchFeature(data=_lowercase   ,						tensor_type=_lowercase)










def 				A			(		__UpperCAmelCase							,					__UpperCAmelCase = 2	)       ->       float:



						'''simple docstring'''






						return round((float(__UpperCAmelCase	) * 9 / 5) + 32							,					__UpperCAmelCase	)







def 				A			(		__UpperCAmelCase							,					__UpperCAmelCase = 2	)       ->       float:



						'''simple docstring'''






						return round(float(__UpperCAmelCase	) + 273.15							,					__UpperCAmelCase	)







def 				A			(		__UpperCAmelCase							,					__UpperCAmelCase = 2	)       ->       float:



						'''simple docstring'''






						return round((float(__UpperCAmelCase	) * 9 / 5) + 491.67							,					__UpperCAmelCase	)







def 				A			(		__UpperCAmelCase							,					__UpperCAmelCase = 2	)       ->       float:



						'''simple docstring'''






						return round((float(__UpperCAmelCase	) - 32) * 5 / 9							,					__UpperCAmelCase	)







def 				A			(		__UpperCAmelCase							,					__UpperCAmelCase = 2	)       ->       float:



						'''simple docstring'''






						return round(((float(__UpperCAmelCase	) - 32) * 5 / 9) + 273.15							,					__UpperCAmelCase	)







def 				A			(		__UpperCAmelCase							,					__UpperCAmelCase = 2	)       ->       float:



						'''simple docstring'''






						return round(float(__UpperCAmelCase	) + 459.67							,					__UpperCAmelCase	)







def 				A			(		__UpperCAmelCase							,					__UpperCAmelCase = 2	)       ->       float:



						'''simple docstring'''






						return round(float(__UpperCAmelCase	) - 273.15							,					__UpperCAmelCase	)







def 				A			(		__UpperCAmelCase							,					__UpperCAmelCase = 2	)       ->       float:



						'''simple docstring'''






						return round(((float(__UpperCAmelCase	) - 273.15) * 9 / 5) + 32							,					__UpperCAmelCase	)







def 				A			(		__UpperCAmelCase							,					__UpperCAmelCase = 2	)       ->       float:



						'''simple docstring'''






						return round((float(__UpperCAmelCase	) * 9 / 5)							,					__UpperCAmelCase	)







def 				A			(		__UpperCAmelCase							,					__UpperCAmelCase = 2	)       ->       float:



						'''simple docstring'''






						return round((float(__UpperCAmelCase	) - 491.67) * 5 / 9							,					__UpperCAmelCase	)







def 				A			(		__UpperCAmelCase							,					__UpperCAmelCase = 2	)       ->       float:



						'''simple docstring'''






						return round(float(__UpperCAmelCase	) - 459.67							,					__UpperCAmelCase	)







def 				A			(		__UpperCAmelCase							,					__UpperCAmelCase = 2	)       ->       float:



						'''simple docstring'''






						return round((float(__UpperCAmelCase	) * 5 / 9)							,					__UpperCAmelCase	)







def 				A			(		__UpperCAmelCase							,					__UpperCAmelCase = 2	)       ->       float:



						'''simple docstring'''






						return round((float(__UpperCAmelCase	) * 1.25 + 273.15)							,					__UpperCAmelCase	)







def 				A			(		__UpperCAmelCase							,					__UpperCAmelCase = 2	)       ->       float:



						'''simple docstring'''






						return round((float(__UpperCAmelCase	) * 2.25 + 32)							,					__UpperCAmelCase	)







def 				A			(		__UpperCAmelCase							,					__UpperCAmelCase = 2	)       ->       float:



						'''simple docstring'''






						return round((float(__UpperCAmelCase	) * 1.25)							,					__UpperCAmelCase	)







def 				A			(		__UpperCAmelCase							,					__UpperCAmelCase = 2	)       ->       float:



						'''simple docstring'''






						return round((float(__UpperCAmelCase	) * 2.25 + 32 + 459.67)							,					__UpperCAmelCase	)


if __name__ == "__main__":
							import doctest

							doctest.testmod()





