






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





				"""simple docstring"""







				def __init__(					self				,    lowerCamelCase__				,    lowerCamelCase__=7				,    lowerCamelCase__=3				,    lowerCamelCase__=18				,    lowerCamelCase__=30				,    lowerCamelCase__=400				,    lowerCamelCase__=True				,    lowerCamelCase__=None				,    lowerCamelCase__=0.875				,    lowerCamelCase__=True				,    lowerCamelCase__=[0.5, 0.5, 0.5]				,    lowerCamelCase__=[0.5, 0.5, 0.5]				,    ):




									"""simple docstring"""

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







				def  __lowercase				(					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 							__A	(     _lowercase ,	unittest.TestCase					):





				"""simple docstring"""







				UpperCamelCase__					: str     					=ConvNextImageProcessor if is_vision_available() else None


				def  __lowercase				(					self       ):




									"""simple docstring"""

									__UpperCamelCase :   List[Any]									=ConvNextImageProcessingTester(self       )


				@property
				def  __lowercase				(					self       ):




									"""simple docstring"""

									return self.image_processor_tester.prepare_image_processor_dict()


				def  __lowercase				(					self       ):




									"""simple docstring"""

									__UpperCamelCase :   Tuple									=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  __lowercase				(					self       ):




									"""simple docstring"""

									__UpperCamelCase :   Union[str, Any]									=self.image_processing_class.from_dict(self.image_processor_dict       )
									self.assertEqual(image_processor.size				,    {'shortest_edge': 20}       )

									__UpperCamelCase :   List[Any]									=self.image_processing_class.from_dict(self.image_processor_dict				,    size=42       )
									self.assertEqual(image_processor.size				,    {'shortest_edge': 42}       )


				def  __lowercase				(					self       ):




									"""simple docstring"""

									pass


				def  __lowercase				(					self       ):




									"""simple docstring"""

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

									# Test not batched input
									__UpperCamelCase :   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
									__UpperCamelCase :   Dict									=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  __lowercase				(					self       ):




									"""simple docstring"""

									__UpperCamelCase :   int									=self.image_processing_class(**self.image_processor_dict       )
									# create random numpy tensors
									__UpperCamelCase :   Optional[Any]									=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
									__UpperCamelCase :   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
									__UpperCamelCase :   str									=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  __lowercase				(					self       ):




									"""simple docstring"""

									__UpperCamelCase :   List[str]									=self.image_processing_class(**self.image_processor_dict       )
									# create random PyTorch tensors
									__UpperCamelCase :   int									=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
									__UpperCamelCase :   Union[str, 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
									__UpperCamelCase :   Any									=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"""





from ..utils import DummyObject, requires_backends





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Union[str, Any]:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Any:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Dict:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Optional[Any]:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Tuple:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Union[str, Any]:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Optional[int]:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Optional[Any]:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Union[str, Any]:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> int:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> List[Any]:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Tuple:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Dict:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Any:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Optional[Any]:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Dict:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Any:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Dict:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> List[str]:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Tuple:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Tuple:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> int:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Optional[Any]:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> int:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Tuple:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Tuple:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> str:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Optional[int]:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Optional[Any]:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Union[str, Any]:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> int:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Any:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Dict:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Optional[int]:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Optional[int]:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Union[str, Any]:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> int:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> List[Any]:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Dict:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Dict:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> List[Any]:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Optional[int]:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Tuple:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> List[Any]:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> List[str]:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> str:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> int:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Dict:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> List[Any]:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> List[str]:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> int:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Optional[int]:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> int:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> str:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> str:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> int:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Dict:
								requires_backends(self ,				["tokenizers"]		)





class 							_lowerCamelCase   (							metaclass=_lowercase			):
						UpperCAmelCase_			=      ["tokenizers"]


						def __init__(self ,				*__a ,				**__a		)			-> Dict:
								requires_backends(self ,				["tokenizers"]		)






