
'''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 				lowerCAmelCase__     (						unittest.TestCase  ):






					def __init__(     self       ,							__SCREAMING_SNAKE_CASE       ,							__SCREAMING_SNAKE_CASE=7       ,							__SCREAMING_SNAKE_CASE=3       ,							__SCREAMING_SNAKE_CASE=18       ,							__SCREAMING_SNAKE_CASE=30       ,							__SCREAMING_SNAKE_CASE=4_00       ,							__SCREAMING_SNAKE_CASE=True       ,							__SCREAMING_SNAKE_CASE=None       ,							__SCREAMING_SNAKE_CASE=0.875       ,							__SCREAMING_SNAKE_CASE=True       ,							__SCREAMING_SNAKE_CASE=[0.5, 0.5, 0.5]       ,							__SCREAMING_SNAKE_CASE=[0.5, 0.5, 0.5]       ,							):


											"""simple docstring"""





											lowercase_			:  List[str]									= size if size is not None else {'''shortest_edge''': 20}
											lowercase_			:  List[Any]									= parent
											lowercase_			:  Any									= batch_size
											lowercase_			:  str									= num_channels
											lowercase_			:  List[str]									= image_size
											lowercase_			:  Optional[Any]									= min_resolution
											lowercase_			:  str									= max_resolution
											lowercase_			:  Optional[Any]									= do_resize
											lowercase_			:  str									= size
											lowercase_			:  Union[str, Any]									= crop_pct
											lowercase_			:  int									= do_normalize
											lowercase_			:  List[str]									= image_mean
											lowercase_			:  Tuple									= image_std






					def 			_snake_case					(     self	):


											"""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 				lowerCAmelCase__     (						lowerCAmelCase_					,		unittest.TestCase  ):
					lowerCAmelCase_       =  ConvNextImageProcessor if is_vision_available() else None






					def 			_snake_case					(     self	):


											"""simple docstring"""





											lowercase_			:  str									= ConvNextImageProcessingTester(self	)






					@property
					def 			_snake_case					(     self	):


											"""simple docstring"""





											return self.image_processor_tester.prepare_image_processor_dict()






					def 			_snake_case					(     self	):


											"""simple docstring"""





											lowercase_			:  Dict									= self.image_processing_class(**self.image_processor_dict	)
											self.assertTrue(hasattr(lowerCamelCase_       ,							'''do_resize'''	)	)
											self.assertTrue(hasattr(lowerCamelCase_       ,							'''size'''	)	)
											self.assertTrue(hasattr(lowerCamelCase_       ,							'''crop_pct'''	)	)
											self.assertTrue(hasattr(lowerCamelCase_       ,							'''do_normalize'''	)	)
											self.assertTrue(hasattr(lowerCamelCase_       ,							'''image_mean'''	)	)
											self.assertTrue(hasattr(lowerCamelCase_       ,							'''image_std'''	)	)






					def 			_snake_case					(     self	):


											"""simple docstring"""





											lowercase_			:  Dict									= self.image_processing_class.from_dict(self.image_processor_dict	)
											self.assertEqual(image_processor.size       ,							{'''shortest_edge''': 20}	)

											lowercase_			:  Optional[int]									= self.image_processing_class.from_dict(self.image_processor_dict       ,							size=42	)
											self.assertEqual(image_processor.size       ,							{'''shortest_edge''': 42}	)






					def 			_snake_case					(     self	):


											"""simple docstring"""





											pass






					def 			_snake_case					(     self	):


											"""simple docstring"""





											lowercase_			:  Any									= self.image_processing_class(**self.image_processor_dict	)
											# create random PIL images
											lowercase_			:  Any									= prepare_image_inputs(self.image_processor_tester       ,							equal_resolution=lowerCamelCase_	)
											for image in image_inputs:
																	self.assertIsInstance(lowerCamelCase_       ,							Image.Image	)

											# Test not batched input
											lowercase_			:  Optional[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
											lowercase_			:  Optional[Any]									= image_processing(lowerCamelCase_       ,							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 			_snake_case					(     self	):


											"""simple docstring"""





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

											# Test not batched input
											lowercase_			:  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
											lowercase_			:  Optional[Any]									= image_processing(lowerCamelCase_       ,							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 			_snake_case					(     self	):


											"""simple docstring"""





											lowercase_			:  Dict									= self.image_processing_class(**self.image_processor_dict	)
											# create random PyTorch tensors
											lowercase_			:  int									= prepare_image_inputs(self.image_processor_tester       ,							equal_resolution=lowerCamelCase_       ,							torchify=lowerCamelCase_	)
											for image in image_inputs:
																	self.assertIsInstance(lowerCamelCase_       ,							torch.Tensor	)

											# Test not batched input
											lowercase_			:  Dict									= 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
											lowercase_			:  str									= image_processing(lowerCamelCase_       ,							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       snake_case_	(       __SCREAMING_SNAKE_CASE      :				int = 1000							):



						"""simple docstring"""





						lowercase_			:  List[Any]									= 0
						for i in range(__SCREAMING_SNAKE_CASE							):
												if i % 3 == 0 or i % 5 == 0:
																		result += i
						return result


if __name__ == "__main__":
							print(f"""{solution() = }""")



