
"""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 ViTImageProcessor




class 			A__	(     unittest.TestCase):

		def __init__(				self	,		_SCREAMING_SNAKE_CASE	,		_SCREAMING_SNAKE_CASE=13	,		_SCREAMING_SNAKE_CASE=3	,		_SCREAMING_SNAKE_CASE=2_24	,		_SCREAMING_SNAKE_CASE=30	,		_SCREAMING_SNAKE_CASE=4_00	,		_SCREAMING_SNAKE_CASE=True	,		_SCREAMING_SNAKE_CASE=None	,		_SCREAMING_SNAKE_CASE=True	,		_SCREAMING_SNAKE_CASE=[0.5, 0.5, 0.5]	,		_SCREAMING_SNAKE_CASE=[0.5, 0.5, 0.5]	,		):
			__lowerCAmelCase      :						Dict						      =				size if size is not None else {'height': 18, 'width': 18}
			__lowerCAmelCase      :						Optional[int]						      =				parent
			__lowerCAmelCase      :						int						      =				batch_size
			__lowerCAmelCase      :						List[str]						      =				num_channels
			__lowerCAmelCase      :						List[str]						      =				image_size
			__lowerCAmelCase      :						Tuple						      =				min_resolution
			__lowerCAmelCase      :						Dict						      =				max_resolution
			__lowerCAmelCase      :						Tuple						      =				do_resize
			__lowerCAmelCase      :						Optional[Any]						      =				size
			__lowerCAmelCase      :						Optional[int]						      =				do_normalize
			__lowerCAmelCase      :						str						      =				image_mean
			__lowerCAmelCase      :						Optional[int]						      =				image_std







		def 							__lowerCamelCase							(				self			):
			return {
			    "image_mean": self.image_mean,
			    "image_std": self.image_std,
			    "do_normalize": self.do_normalize,
			    "do_resize": self.do_resize,
			    "size": self.size,
			}




@require_torch
@require_vision
class 			A__	(     _lowerCamelCase	,					unittest.TestCase):
		A_						:	Optional[Any]           =     ViTImageProcessor if is_vision_available() else None

		def 							__lowerCamelCase							(				self			):
			__lowerCAmelCase      :						Any						      =				EfficientFormerImageProcessorTester(self			)

		@property
		def 							__lowerCamelCase							(				self			):
			return self.image_proc_tester.prepare_image_processor_dict()

		def 							__lowerCamelCase							(				self			):
			__lowerCAmelCase      :						Optional[Any]						      =				self.image_processing_class(**self.image_processor_dict			)
			self.assertTrue(hasattr(_SCREAMING_SNAKE_CASE	,		'image_mean'			)			)
			self.assertTrue(hasattr(_SCREAMING_SNAKE_CASE	,		'image_std'			)			)
			self.assertTrue(hasattr(_SCREAMING_SNAKE_CASE	,		'do_normalize'			)			)
			self.assertTrue(hasattr(_SCREAMING_SNAKE_CASE	,		'do_resize'			)			)
			self.assertTrue(hasattr(_SCREAMING_SNAKE_CASE	,		'size'			)			)

		def 							__lowerCamelCase							(				self			):
			pass

		def 							__lowerCamelCase							(				self			):
			# Initialize image_processor
			__lowerCAmelCase      :						int						      =				self.image_processing_class(**self.image_processor_dict			)
			# create random PIL images
			__lowerCAmelCase      :						Optional[int]						      =				prepare_image_inputs(self.image_proc_tester	,		equal_resolution=_SCREAMING_SNAKE_CASE			)
			for image in image_inputs:
				self.assertIsInstance(_SCREAMING_SNAKE_CASE	,		Image.Image			)

			# Test not batched input
			__lowerCAmelCase      :						Dict						      =				image_processor(image_inputs[0]	,		return_tensors='pt'			).pixel_values
			self.assertEqual(
			    encoded_images.shape	,		(
			        1,
			        self.image_proc_tester.num_channels,
			        self.image_proc_tester.size['height'],
			        self.image_proc_tester.size['width'],
			    )	,		)

			# Test batched
			__lowerCAmelCase      :						Dict						      =				image_processor(_SCREAMING_SNAKE_CASE	,		return_tensors='pt'			).pixel_values
			self.assertEqual(
			    encoded_images.shape	,		(
			        self.image_proc_tester.batch_size,
			        self.image_proc_tester.num_channels,
			        self.image_proc_tester.size['height'],
			        self.image_proc_tester.size['width'],
			    )	,		)

		def 							__lowerCamelCase							(				self			):
			# Initialize image_processor
			__lowerCAmelCase      :						Union[str, Any]						      =				self.image_processing_class(**self.image_processor_dict			)
			# create random numpy tensors
			__lowerCAmelCase      :						str						      =				prepare_image_inputs(self.image_proc_tester	,		equal_resolution=_SCREAMING_SNAKE_CASE	,		numpify=_SCREAMING_SNAKE_CASE			)
			for image in image_inputs:
				self.assertIsInstance(_SCREAMING_SNAKE_CASE	,		np.ndarray			)

			# Test not batched input
			__lowerCAmelCase      :						List[str]						      =				image_processor(image_inputs[0]	,		return_tensors='pt'			).pixel_values
			self.assertEqual(
			    encoded_images.shape	,		(
			        1,
			        self.image_proc_tester.num_channels,
			        self.image_proc_tester.size['height'],
			        self.image_proc_tester.size['width'],
			    )	,		)

			# Test batched
			__lowerCAmelCase      :						Optional[Any]						      =				image_processor(_SCREAMING_SNAKE_CASE	,		return_tensors='pt'			).pixel_values
			self.assertEqual(
			    encoded_images.shape	,		(
			        self.image_proc_tester.batch_size,
			        self.image_proc_tester.num_channels,
			        self.image_proc_tester.size['height'],
			        self.image_proc_tester.size['width'],
			    )	,		)







		def 							__lowerCamelCase							(				self			):
			# Initialize image_processor
			__lowerCAmelCase      :						Optional[int]						      =				self.image_processing_class(**self.image_processor_dict			)
			# create random PyTorch tensors
			__lowerCAmelCase      :						str						      =				prepare_image_inputs(self.image_proc_tester	,		equal_resolution=_SCREAMING_SNAKE_CASE	,		torchify=_SCREAMING_SNAKE_CASE			)
			for image in image_inputs:
				self.assertIsInstance(_SCREAMING_SNAKE_CASE	,		torch.Tensor			)

			# Test not batched input
			__lowerCAmelCase      :						Union[str, Any]						      =				image_processor(image_inputs[0]	,		return_tensors='pt'			).pixel_values
			self.assertEqual(
			    encoded_images.shape	,		(
			        1,
			        self.image_proc_tester.num_channels,
			        self.image_proc_tester.size['height'],
			        self.image_proc_tester.size['width'],
			    )	,		)

			# Test batched
			__lowerCAmelCase      :						List[str]						      =				image_processor(_SCREAMING_SNAKE_CASE	,		return_tensors='pt'			).pixel_values
			self.assertEqual(
			    encoded_images.shape	,		(
			        self.image_proc_tester.batch_size,
			        self.image_proc_tester.num_channels,
			        self.image_proc_tester.size['height'],
			        self.image_proc_tester.size['width'],
			    )	,		)

"""simple docstring"""







from .glue import glue_convert_examples_to_features, glue_output_modes, glue_processors, glue_tasks_num_labels
from .squad import SquadExample, SquadFeatures, SquadVaProcessor, SquadVaProcessor, squad_convert_examples_to_features
from .utils import DataProcessor, InputExample, InputFeatures, SingleSentenceClassificationProcessor
from .xnli import xnli_output_modes, xnli_processors, xnli_tasks_num_labels