


"""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					:				str			,      a__					:				Dict			,      a__					:				List[Any]=7			,      a__					:				Union[str, Any]=3			,      a__					:				Dict=18			,      a__					:				Tuple=30			,      a__					:				List[Any]=4_00			,      a__					:				Optional[int]=True			,      a__					:				Any=None			,      a__					:				List[str]=0.8_7_5			,      a__					:				int=True			,      a__					:				List[str]=[0.5, 0.5, 0.5]			,      a__					:				List[str]=[0.5, 0.5, 0.5]			,      )				->  str:





						'''simple docstring'''







						_A         =	size if size is not None else {"shortest_edge": 20}
						_A         =	parent
						_A         =	batch_size
						_A         =	num_channels
						_A         =	image_size
						_A         =	min_resolution
						_A         =	max_resolution
						_A         =	do_resize
						_A         =	size
						_A         =	crop_pct
						_A         =	do_normalize
						_A         =	image_mean
						_A         =	image_std







		def        a_       (    self					:				Dict						)				->  List[Any]:





						'''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					(     _UpperCamelCase   , unittest.TestCase):
		__UpperCamelCase							=	ConvNextImageProcessor if is_vision_available() else None







		def        a_       (    self					:				Optional[int]						)				->  Optional[Any]:





						'''simple docstring'''







						_A         =	ConvNextImageProcessingTester(self						)







		@property
		def        a_       (    self					:				int						)				->  List[Any]:





						'''simple docstring'''







						return self.image_processor_tester.prepare_image_processor_dict()







		def        a_       (    self					:				Union[str, Any]						)				->  List[Any]:





						'''simple docstring'''







						_A         =	self.image_processing_class(**self.image_processor_dict						)
						self.assertTrue(hasattr(a__			,      "do_resize"						)						)
						self.assertTrue(hasattr(a__			,      "size"						)						)
						self.assertTrue(hasattr(a__			,      "crop_pct"						)						)
						self.assertTrue(hasattr(a__			,      "do_normalize"						)						)
						self.assertTrue(hasattr(a__			,      "image_mean"						)						)
						self.assertTrue(hasattr(a__			,      "image_std"						)						)







		def        a_       (    self					:				Dict						)				->  Any:





						'''simple docstring'''







						_A         =	self.image_processing_class.from_dict(self.image_processor_dict						)
						self.assertEqual(image_processor.size			,      {"shortest_edge": 20}						)

						_A         =	self.image_processing_class.from_dict(self.image_processor_dict			,      size=42						)
						self.assertEqual(image_processor.size			,      {"shortest_edge": 42}						)







		def        a_       (    self					:				Any						)				->  Any:





						'''simple docstring'''







						pass







		def        a_       (    self					:				Optional[Any]						)				->  Any:





						'''simple docstring'''







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

						# Test not batched input
						_A         =	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         =	image_processing(a__			,      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        a_       (    self					:				Union[str, Any]						)				->  Optional[int]:





						'''simple docstring'''







						_A         =	self.image_processing_class(**self.image_processor_dict						)
						# create random numpy tensors
						_A         =	prepare_image_inputs(self.image_processor_tester			,      equal_resolution=a__			,      numpify=a__						)
						for image in image_inputs:
										self.assertIsInstance(a__			,      np.ndarray						)

						# Test not batched input
						_A         =	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         =	image_processing(a__			,      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        a_       (    self					:				Union[str, Any]						)				->  Dict:





						'''simple docstring'''







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

						# Test not batched input
						_A         =	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         =	image_processing(a__			,      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 		_lowercase		(	lowercase_  ):



		'''simple docstring'''







		return "".join(chr(ord(lowercase_  ) + 32  ) if "A" <= char <= "Z" else char for char in word  )


if __name__ == "__main__":
						from doctest import testmod

						testmod()





