



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



						"""simple docstring"""






						def __init__(   self					:Optional[Any]  ,    lowercase_					:Union[str, Any]  ,    lowercase_					:List[Any]=7  ,    lowercase_					:Optional[Any]=3  ,    lowercase_					:Optional[int]=18  ,    lowercase_					:Dict=30  ,    lowercase_					:Dict=4_00  ,    lowercase_					:List[Any]=True  ,    lowercase_					:int=None  ,    lowercase_					:List[Any]=0.875  ,    lowercase_					:List[str]=True  ,    lowercase_					:List[Any]=[0.5, 0.5, 0.5]  ,    lowercase_					:Optional[Any]=[0.5, 0.5, 0.5]  ,    )							->     Optional[Any]:
												UpperCAmelCase			 =					size if size is not None else {"shortest_edge": 20}
												UpperCAmelCase			 =					parent
												UpperCAmelCase			 =					batch_size
												UpperCAmelCase			 =					num_channels
												UpperCAmelCase			 =					image_size
												UpperCAmelCase			 =					min_resolution
												UpperCAmelCase			 =					max_resolution
												UpperCAmelCase			 =					do_resize
												UpperCAmelCase			 =					size
												UpperCAmelCase			 =					crop_pct
												UpperCAmelCase			 =					do_normalize
												UpperCAmelCase			 =					image_mean
												UpperCAmelCase			 =					image_std






						def       UpperCAmelCase__	(   self					:Dict   )							->     Tuple:
												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_     (	SCREAMING_SNAKE_CASE_      ,  unittest.TestCase							):



						"""simple docstring"""
						__UpperCamelCase													=				ConvNextImageProcessor if is_vision_available() else None






						def       UpperCAmelCase__	(   self					:Dict   )							->     Union[str, Any]:
												UpperCAmelCase			 =					ConvNextImageProcessingTester(self   )






						@property
						def       UpperCAmelCase__	(   self					:str   )							->     List[str]:
												return self.image_processor_tester.prepare_image_processor_dict()






						def       UpperCAmelCase__	(   self					:Union[str, Any]   )							->     int:
												UpperCAmelCase			 =					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       UpperCAmelCase__	(   self					:Optional[int]   )							->     str:
												UpperCAmelCase			 =					self.image_processing_class.from_dict(self.image_processor_dict   )
												self.assertEqual(image_processor.size  ,    {'shortest_edge': 20}   )

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






						def       UpperCAmelCase__	(   self					:List[str]   )							->     List[str]:
												pass






						def       UpperCAmelCase__	(   self					:Tuple   )							->     Optional[Any]:
												UpperCAmelCase			 =					self.image_processing_class(**self.image_processor_dict   )
												# create random PIL images
												UpperCAmelCase			 =					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			 =					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			 =					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       UpperCAmelCase__	(   self					:Optional[int]   )							->     Union[str, Any]:
												UpperCAmelCase			 =					self.image_processing_class(**self.image_processor_dict   )
												# create random numpy tensors
												UpperCAmelCase			 =					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			 =					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			 =					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       UpperCAmelCase__	(   self					:List[Any]   )							->     str:
												UpperCAmelCase			 =					self.image_processing_class(**self.image_processor_dict   )
												# create random PyTorch tensors
												UpperCAmelCase			 =					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			 =					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			 =					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 						_snake_case		(     SCREAMING_SNAKE_CASE		,				SCREAMING_SNAKE_CASE		,				SCREAMING_SNAKE_CASE					)							->   Optional[int]:

     """simple docstring"""







     if power < 0:
          return -1
     base %= mod
     _lowerCAmelCase :       Tuple	   =     1

     while power > 0:
          if power & 1:
               _lowerCAmelCase :       Optional[Any]	   =     (result * base) % mod
          _lowerCAmelCase :       int	   =     power >> 1
          _lowerCAmelCase :       Optional[int]	   =     (base * base) % mod

     return result







def 						_snake_case		(     )							->   Optional[int]:

     """simple docstring"""







     print(modular_exponential(3		,				200		,				13					)					)


if __name__ == "__main__":
  import doctest

  doctest.testmod()

  main()






