

"""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       :    List[Any] ,		a       :    Tuple ,		a       :    Optional[Any]=7 ,		a       :    List[str]=3 ,		a       :    Dict=18 ,		a       :    Tuple=30 ,		a       :    Tuple=400 ,		a       :    Union[str, Any]=True ,		a       :    Optional[Any]=None ,		a       :    Optional[Any]=0.875 ,		a       :    Optional[Any]=True ,		a       :    int=[0.5, 0.5, 0.5] ,		a       :    str=[0.5, 0.5, 0.5] ,		)   ->    str:

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

							def 					_lowerCAmelCase  ( self       :    Any    )   ->    Union[str, 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 	_lowerCAmelCase    (      __snake_case       ,       unittest.TestCase       ):
							__lowerCAmelCase					:    Any     =  ConvNextImageProcessor if is_vision_available() else None

							def 					_lowerCAmelCase  ( self       :    Optional[Any]    )   ->    List[Any]:

									"""simple docstring"""
									lowercase										=							ConvNextImageProcessingTester(self    )

							@property
							def 					_lowerCAmelCase  ( self       :    str    )   ->    List[Any]:

									"""simple docstring"""
									return self.image_processor_tester.prepare_image_processor_dict()

							def 					_lowerCAmelCase  ( self       :    Tuple    )   ->    Tuple:

									"""simple docstring"""
									lowercase										=							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 					_lowerCAmelCase  ( self       :    List[Any]    )   ->    str:

									"""simple docstring"""
									lowercase										=							self.image_processing_class.from_dict(self.image_processor_dict    )
									self.assertEqual(image_processor.size ,		{'''shortest_edge''': 20}    )

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

							def 					_lowerCAmelCase  ( self       :    Any    )   ->    List[Any]:

									"""simple docstring"""
									pass

							def 					_lowerCAmelCase  ( self       :    int    )   ->    int:

									"""simple docstring"""
									# Initialize image_processing
									lowercase										=							self.image_processing_class(**self.image_processor_dict    )
									# create random PIL images
									lowercase										=							prepare_image_inputs(self.image_processor_tester ,		equal_resolution=a    )
									for image in image_inputs:
											self.assertIsInstance(a ,		Image.Image    )

									# Test not batched input
									lowercase										=							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										=							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 					_lowerCAmelCase  ( self       :    List[str]    )   ->    Optional[Any]:

									"""simple docstring"""
									# Initialize image_processing
									lowercase										=							self.image_processing_class(**self.image_processor_dict    )
									# create random numpy tensors
									lowercase										=							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
									lowercase										=							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										=							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 					_lowerCAmelCase  ( self       :    List[str]    )   ->    Optional[Any]:

									"""simple docstring"""
									# Initialize image_processing
									lowercase										=							self.image_processing_class(**self.image_processor_dict    )
									# create random PyTorch tensors
									lowercase										=							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
									lowercase										=							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										=							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 typing import TYPE_CHECKING

from ...utils import _LazyModule


__lowerCAmelCase				      =   {'''tokenization_phobert''': ['''PhobertTokenizer''']}


if TYPE_CHECKING:
							from .tokenization_phobert import PhobertTokenizer

else:
							import sys

							__lowerCAmelCase				      =   _LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)