




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






      def __init__(   self      :     List[Any]	,	lowercase__      :     Optional[Any]	,	lowercase__      :     List[str]=7	,	lowercase__      :     Optional[Any]=3	,	lowercase__      :     Union[str, Any]=18	,	lowercase__      :     str=30	,	lowercase__      :     int=400	,	lowercase__      :     Union[str, Any]=True	,	lowercase__      :     Dict=None	,	lowercase__      :     Dict=0.875	,	lowercase__      :     Union[str, Any]=True	,	lowercase__      :     Optional[int]=[0.5, 0.5, 0.5]	,	lowercase__      :     Optional[int]=[0.5, 0.5, 0.5]	,	):


           '''simple docstring'''

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






      def        lowercase_	(   self      :     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     SCREAMING_SNAKE_CASE						(	__UpperCAmelCase       ,			unittest.TestCase							):
      __magic_name__     :					Tuple             =				ConvNextImageProcessor if is_vision_available() else None






      def        lowercase_	(   self      :     Optional[Any]					):


           '''simple docstring'''

           a_    :       List[Any]    	=     ConvNextImageProcessingTester(self					)






      @property
      def        lowercase_	(   self      :     Optional[Any]					):


           '''simple docstring'''

           return self.image_processor_tester.prepare_image_processor_dict()






      def        lowercase_	(   self      :     Union[str, Any]					):


           '''simple docstring'''

           a_    :       List[Any]    	=     self.image_processing_class(**self.image_processor_dict					)
           self.assertTrue(hasattr(lowercase_	,	"""do_resize"""					)					)
           self.assertTrue(hasattr(lowercase_	,	"""size"""					)					)
           self.assertTrue(hasattr(lowercase_	,	"""crop_pct"""					)					)
           self.assertTrue(hasattr(lowercase_	,	"""do_normalize"""					)					)
           self.assertTrue(hasattr(lowercase_	,	"""image_mean"""					)					)
           self.assertTrue(hasattr(lowercase_	,	"""image_std"""					)					)






      def        lowercase_	(   self      :     int					):


           '''simple docstring'''

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

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






      def        lowercase_	(   self      :     Union[str, Any]					):


           '''simple docstring'''

           pass






      def        lowercase_	(   self      :     List[Any]					):


           '''simple docstring'''

           a_    :       Tuple    	=     self.image_processing_class(**self.image_processor_dict					)
           # create random PIL images
           a_    :       List[str]    	=     prepare_image_inputs(self.image_processor_tester	,	equal_resolution=lowercase_					)
           for image in image_inputs:
                self.assertIsInstance(lowercase_	,	Image.Image					)

           # Test not batched input
           a_    :       List[str]    	=     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_    :       int    	=     image_processing(lowercase_	,	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      :     Tuple					):


           '''simple docstring'''

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

           # Test not batched input
           a_    :       List[str]    	=     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_    :       Union[str, Any]    	=     image_processing(lowercase_	,	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      :     List[str]					):


           '''simple docstring'''

           a_    :       Union[str, Any]    	=     self.image_processing_class(**self.image_processor_dict					)
           # create random PyTorch tensors
           a_    :       Dict    	=     prepare_image_inputs(self.image_processor_tester	,	equal_resolution=lowercase_	,	torchify=lowercase_					)
           for image in image_inputs:
                self.assertIsInstance(lowercase_	,	torch.Tensor					)

           # Test not batched input
           a_    :       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
           a_    :       List[Any]    	=     image_processing(lowercase_	,	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    _SCREAMING_SNAKE_CASE    (			UpperCamelCase__						:				int = 1000							):




     """simple docstring"""


     return sum(i for i in range(UpperCamelCase__							) if i % 3 == 0 or i % 5 == 0							)


if __name__ == "__main__":
 print(f"{solution() = }")
