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


if is_torch_available():
			import torch

if is_vision_available():
			from PIL import Image

			from transformers import ConvNextImageProcessor




class  _snake_case	(    unittest.TestCase							):






							def __init__(       self    :      Dict    ,			snake_case__    :      List[Any]    ,			snake_case__    :      List[str]=7    ,			snake_case__    :      int=3    ,			snake_case__    :      Dict=1_8    ,			snake_case__    :      List[str]=3_0    ,			snake_case__    :      Optional[Any]=4_0_0    ,			snake_case__    :      Any=True    ,			snake_case__    :      Optional[Any]=None    ,			snake_case__    :      Union[str, Any]=0.875    ,			snake_case__    :      List[Any]=True    ,			snake_case__    :      List[str]=[0.5, 0.5, 0.5]    ,			snake_case__    :      List[str]=[0.5, 0.5, 0.5]    ,			):






												"""simple docstring"""



												__a:    Tuple		     =       size if size is not None else {"""shortest_edge""": 2_0}
												__a:    int		     =       parent
												__a:    int		     =       batch_size
												__a:    List[Any]		     =       num_channels
												__a:    str		     =       image_size
												__a:    int		     =       min_resolution
												__a:    int		     =       max_resolution
												__a:    Tuple		     =       do_resize
												__a:    List[str]		     =       size
												__a:    str		     =       crop_pct
												__a:    str		     =       do_normalize
												__a:    Tuple		     =       image_mean
												__a:    Tuple		     =       image_std






							def 				__lowercase	(       self    :      Dict     ):






												"""simple docstring"""



												return {
												    "image_mean": self.image_mean,
												    "image_std": self.image_std,
												    "do_normalize": self.do_normalize,
												    "do_resize": self.do_resize,
												    "size": self.size,
												    "crop_pct": self.crop_pct,
												}






@require_torch
@require_vision
class  _snake_case	(    _lowercase			,					unittest.TestCase							):
							SCREAMING_SNAKE_CASE		  =    ConvNextImageProcessor if is_vision_available() else None






							def 				__lowercase	(       self    :      Union[str, Any]     ):






												"""simple docstring"""



												__a:    List[str]		     =       ConvNextImageProcessingTester(self     )






							@property
							def 				__lowercase	(       self    :      Tuple     ):






												"""simple docstring"""



												return self.image_processor_tester.prepare_image_processor_dict()






							def 				__lowercase	(       self    :      Optional[Any]     ):






												"""simple docstring"""



												__a:    Dict		     =       self.image_processing_class(**self.image_processor_dict     )
												self.assertTrue(hasattr(snake_case__    ,			"""do_resize"""     )     )
												self.assertTrue(hasattr(snake_case__    ,			"""size"""     )     )
												self.assertTrue(hasattr(snake_case__    ,			"""crop_pct"""     )     )
												self.assertTrue(hasattr(snake_case__    ,			"""do_normalize"""     )     )
												self.assertTrue(hasattr(snake_case__    ,			"""image_mean"""     )     )
												self.assertTrue(hasattr(snake_case__    ,			"""image_std"""     )     )






							def 				__lowercase	(       self    :      Any     ):






												"""simple docstring"""



												__a:    int		     =       self.image_processing_class.from_dict(self.image_processor_dict     )
												self.assertEqual(image_processor.size    ,			{"""shortest_edge""": 2_0}     )

												__a:    Optional[int]		     =       self.image_processing_class.from_dict(self.image_processor_dict    ,			size=4_2     )
												self.assertEqual(image_processor.size    ,			{"""shortest_edge""": 4_2}     )






							def 				__lowercase	(       self    :      List[str]     ):






												"""simple docstring"""



												pass






							def 				__lowercase	(       self    :      Optional[int]     ):






												"""simple docstring"""



												__a:    Union[str, Any]		     =       self.image_processing_class(**self.image_processor_dict     )
												# create random PIL images
												__a:    int		     =       prepare_image_inputs(self.image_processor_tester    ,			equal_resolution=snake_case__     )
												for image in image_inputs:
																	self.assertIsInstance(snake_case__    ,			Image.Image     )

												# Test not batched input
												__a:    List[str]		     =       image_processing(image_inputs[0]    ,			return_tensors="""pt"""     ).pixel_values
												self.assertEqual(
												    encoded_images.shape    ,			(
												        1,
												        self.image_processor_tester.num_channels,
												        self.image_processor_tester.size["""shortest_edge"""],
												        self.image_processor_tester.size["""shortest_edge"""],
												    )    ,			)

												# Test batched
												__a:    List[Any]		     =       image_processing(snake_case__    ,			return_tensors="""pt"""     ).pixel_values
												self.assertEqual(
												    encoded_images.shape    ,			(
												        self.image_processor_tester.batch_size,
												        self.image_processor_tester.num_channels,
												        self.image_processor_tester.size["""shortest_edge"""],
												        self.image_processor_tester.size["""shortest_edge"""],
												    )    ,			)






							def 				__lowercase	(       self    :      Tuple     ):






												"""simple docstring"""



												__a:    List[str]		     =       self.image_processing_class(**self.image_processor_dict     )
												# create random numpy tensors
												__a:    Union[str, Any]		     =       prepare_image_inputs(self.image_processor_tester    ,			equal_resolution=snake_case__    ,			numpify=snake_case__     )
												for image in image_inputs:
																	self.assertIsInstance(snake_case__    ,			np.ndarray     )

												# Test not batched input
												__a:    Any		     =       image_processing(image_inputs[0]    ,			return_tensors="""pt"""     ).pixel_values
												self.assertEqual(
												    encoded_images.shape    ,			(
												        1,
												        self.image_processor_tester.num_channels,
												        self.image_processor_tester.size["""shortest_edge"""],
												        self.image_processor_tester.size["""shortest_edge"""],
												    )    ,			)

												# Test batched
												__a:    str		     =       image_processing(snake_case__    ,			return_tensors="""pt"""     ).pixel_values
												self.assertEqual(
												    encoded_images.shape    ,			(
												        self.image_processor_tester.batch_size,
												        self.image_processor_tester.num_channels,
												        self.image_processor_tester.size["""shortest_edge"""],
												        self.image_processor_tester.size["""shortest_edge"""],
												    )    ,			)






							def 				__lowercase	(       self    :      List[str]     ):






												"""simple docstring"""



												__a:    List[str]		     =       self.image_processing_class(**self.image_processor_dict     )
												# create random PyTorch tensors
												__a:    str		     =       prepare_image_inputs(self.image_processor_tester    ,			equal_resolution=snake_case__    ,			torchify=snake_case__     )
												for image in image_inputs:
																	self.assertIsInstance(snake_case__    ,			torch.Tensor     )

												# Test not batched input
												__a:    str		     =       image_processing(image_inputs[0]    ,			return_tensors="""pt"""     ).pixel_values
												self.assertEqual(
												    encoded_images.shape    ,			(
												        1,
												        self.image_processor_tester.num_channels,
												        self.image_processor_tester.size["""shortest_edge"""],
												        self.image_processor_tester.size["""shortest_edge"""],
												    )    ,			)

												# Test batched
												__a:    Optional[Any]		     =       image_processing(snake_case__    ,			return_tensors="""pt"""     ).pixel_values
												self.assertEqual(
												    encoded_images.shape    ,			(
												        self.image_processor_tester.batch_size,
												        self.image_processor_tester.num_channels,
												        self.image_processor_tester.size["""shortest_edge"""],
												        self.image_processor_tester.size["""shortest_edge"""],
												    )    ,			)


"""simple docstring"""
def      lowerCamelCase_     (						lowerCamelCase_						,					lowerCamelCase_ = 2			)  ->      float:


					'''simple docstring'''
					return round((float(lowerCamelCase_			) * 9 / 5) + 32						,					lowerCamelCase_			)


def      lowerCamelCase_     (						lowerCamelCase_						,					lowerCamelCase_ = 2			)  ->      float:


					'''simple docstring'''
					return round(float(lowerCamelCase_			) + 273.15						,					lowerCamelCase_			)


def      lowerCamelCase_     (						lowerCamelCase_						,					lowerCamelCase_ = 2			)  ->      float:


					'''simple docstring'''
					return round((float(lowerCamelCase_			) * 9 / 5) + 491.67						,					lowerCamelCase_			)


def      lowerCamelCase_     (						lowerCamelCase_						,					lowerCamelCase_ = 2			)  ->      float:


					'''simple docstring'''
					return round((float(lowerCamelCase_			) - 32) * 5 / 9						,					lowerCamelCase_			)


def      lowerCamelCase_     (						lowerCamelCase_						,					lowerCamelCase_ = 2			)  ->      float:


					'''simple docstring'''
					return round(((float(lowerCamelCase_			) - 32) * 5 / 9) + 273.15						,					lowerCamelCase_			)


def      lowerCamelCase_     (						lowerCamelCase_						,					lowerCamelCase_ = 2			)  ->      float:


					'''simple docstring'''
					return round(float(lowerCamelCase_			) + 459.67						,					lowerCamelCase_			)


def      lowerCamelCase_     (						lowerCamelCase_						,					lowerCamelCase_ = 2			)  ->      float:


					'''simple docstring'''
					return round(float(lowerCamelCase_			) - 273.15						,					lowerCamelCase_			)


def      lowerCamelCase_     (						lowerCamelCase_						,					lowerCamelCase_ = 2			)  ->      float:


					'''simple docstring'''
					return round(((float(lowerCamelCase_			) - 273.15) * 9 / 5) + 32						,					lowerCamelCase_			)


def      lowerCamelCase_     (						lowerCamelCase_						,					lowerCamelCase_ = 2			)  ->      float:


					'''simple docstring'''
					return round((float(lowerCamelCase_			) * 9 / 5)						,					lowerCamelCase_			)


def      lowerCamelCase_     (						lowerCamelCase_						,					lowerCamelCase_ = 2			)  ->      float:


					'''simple docstring'''
					return round((float(lowerCamelCase_			) - 491.67) * 5 / 9						,					lowerCamelCase_			)


def      lowerCamelCase_     (						lowerCamelCase_						,					lowerCamelCase_ = 2			)  ->      float:


					'''simple docstring'''
					return round(float(lowerCamelCase_			) - 459.67						,					lowerCamelCase_			)


def      lowerCamelCase_     (						lowerCamelCase_						,					lowerCamelCase_ = 2			)  ->      float:


					'''simple docstring'''
					return round((float(lowerCamelCase_			) * 5 / 9)						,					lowerCamelCase_			)


def      lowerCamelCase_     (						lowerCamelCase_						,					lowerCamelCase_ = 2			)  ->      float:


					'''simple docstring'''
					return round((float(lowerCamelCase_			) * 1.25 + 273.15)						,					lowerCamelCase_			)


def      lowerCamelCase_     (						lowerCamelCase_						,					lowerCamelCase_ = 2			)  ->      float:


					'''simple docstring'''
					return round((float(lowerCamelCase_			) * 2.25 + 32)						,					lowerCamelCase_			)


def      lowerCamelCase_     (						lowerCamelCase_						,					lowerCamelCase_ = 2			)  ->      float:


					'''simple docstring'''
					return round((float(lowerCamelCase_			) * 1.25)						,					lowerCamelCase_			)


def      lowerCamelCase_     (						lowerCamelCase_						,					lowerCamelCase_ = 2			)  ->      float:


					'''simple docstring'''
					return round((float(lowerCamelCase_			) * 2.25 + 32 + 459.67)						,					lowerCamelCase_			)


if __name__ == "__main__":
			import doctest

			doctest.testmod()
