
'''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


if is_torch_available():
    import torch

if is_vision_available():
    from PIL import Image

    from transformers import CLIPImageProcessor







class 		snake_case_       (						unittest.TestCase						):



   """simple docstring"""





   def __init__( self			,   UpperCamelCase			,   UpperCamelCase=7			,   UpperCamelCase=3			,   UpperCamelCase=18			,   UpperCamelCase=30			,   UpperCamelCase=4_00			,   UpperCamelCase=True			,   UpperCamelCase=None			,   UpperCamelCase=True			,   UpperCamelCase=None			,   UpperCamelCase=True			,   UpperCamelCase=[0.4_8_1_4_5_4_6_6, 0.4_5_7_8_2_7_5, 0.4_0_8_2_1_0_7_3]			,   UpperCamelCase=[0.2_6_8_6_2_9_5_4, 0.2_6_1_3_0_2_5_8, 0.2_7_5_7_7_7_1_1]			,   UpperCamelCase=True			,   ):
          lowerCamelCase__				   =      size if size is not None else {"shortest_edge": 20}
          lowerCamelCase__				   =      crop_size if crop_size is not None else {"height": 18, "width": 18}
          lowerCamelCase__				   =      parent
          lowerCamelCase__				   =      batch_size
          lowerCamelCase__				   =      num_channels
          lowerCamelCase__				   =      image_size
          lowerCamelCase__				   =      min_resolution
          lowerCamelCase__				   =      max_resolution
          lowerCamelCase__				   =      do_resize
          lowerCamelCase__				   =      size
          lowerCamelCase__				   =      do_center_crop
          lowerCamelCase__				   =      crop_size
          lowerCamelCase__				   =      do_normalize
          lowerCamelCase__				   =      image_mean
          lowerCamelCase__				   =      image_std
          lowerCamelCase__				   =      do_convert_rgb







   def     __UpperCAmelCase      ( self):
          return {
              "do_resize": self.do_resize,
              "size": self.size,
              "do_center_crop": self.do_center_crop,
              "crop_size": self.crop_size,
              "do_normalize": self.do_normalize,
              "image_mean": self.image_mean,
              "image_std": self.image_std,
              "do_convert_rgb": self.do_convert_rgb,
          }







   def     __UpperCAmelCase      ( self			,   UpperCamelCase=False			,   UpperCamelCase=False			,   UpperCamelCase=False):
          assert not (numpify and torchify), "You cannot specify both numpy and PyTorch tensors at the same time"

          if equal_resolution:
                 lowerCamelCase__				   =      []
                 for i in range(self.batch_size):
                        image_inputs.append(
                            np.random.randint(
                                2_55			,   size=(self.num_channels, self.max_resolution, self.max_resolution)			,   dtype=np.uinta))
          else:
                 lowerCamelCase__				   =      []
                 for i in range(self.batch_size):
                        lowerCamelCase__   ,		lowerCamelCase__				   =      np.random.choice(np.arange(self.min_resolution			,   self.max_resolution)			,   2)
                        image_inputs.append(np.random.randint(2_55			,   size=(self.num_channels, width, height)			,   dtype=np.uinta))

          if not numpify and not torchify:
                 # PIL expects the channel dimension as last dimension
                 lowerCamelCase__				   =      [Image.fromarray(np.moveaxis(UpperCamelCase			,   0			,   -1)) for x in image_inputs]

          if torchify:
                 lowerCamelCase__				   =      [torch.from_numpy(UpperCamelCase) for x in image_inputs]

          return image_inputs







@require_torch
@require_vision
class 		snake_case_       (						A__		,	unittest.TestCase						):



   """simple docstring"""





   __lowerCAmelCase	:							Dict								=CLIPImageProcessor if is_vision_available() else None







   def     __UpperCAmelCase      ( self):
          lowerCamelCase__				   =      CLIPImageProcessingTester(self)







   @property
   def     __UpperCAmelCase      ( self):
          return self.image_processor_tester.prepare_image_processor_dict()







   def     __UpperCAmelCase      ( self):
          lowerCamelCase__				   =      self.image_processing_class(**self.image_processor_dict)
          self.assertTrue(hasattr(UpperCamelCase			,   "do_resize"))
          self.assertTrue(hasattr(UpperCamelCase			,   "size"))
          self.assertTrue(hasattr(UpperCamelCase			,   "do_center_crop"))
          self.assertTrue(hasattr(UpperCamelCase			,   "center_crop"))
          self.assertTrue(hasattr(UpperCamelCase			,   "do_normalize"))
          self.assertTrue(hasattr(UpperCamelCase			,   "image_mean"))
          self.assertTrue(hasattr(UpperCamelCase			,   "image_std"))
          self.assertTrue(hasattr(UpperCamelCase			,   "do_convert_rgb"))







   def     __UpperCAmelCase      ( self):
          lowerCamelCase__				   =      self.image_processing_class.from_dict(self.image_processor_dict)
          self.assertEqual(image_processor.size			,   {"shortest_edge": 20})
          self.assertEqual(image_processor.crop_size			,   {"height": 18, "width": 18})

          lowerCamelCase__				   =      self.image_processing_class.from_dict(self.image_processor_dict			,   size=42			,   crop_size=84)
          self.assertEqual(image_processor.size			,   {"shortest_edge": 42})
          self.assertEqual(image_processor.crop_size			,   {"height": 84, "width": 84})







   def     __UpperCAmelCase      ( self):
          pass







   def     __UpperCAmelCase      ( self):
          # Initialize image_processing
          lowerCamelCase__				   =      self.image_processing_class(**self.image_processor_dict)
          # create random PIL images
          lowerCamelCase__				   =      self.image_processor_tester.prepare_inputs(equal_resolution=UpperCamelCase)
          for image in image_inputs:
                 self.assertIsInstance(UpperCamelCase			,   Image.Image)

          # Test not batched input
          lowerCamelCase__				   =      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.crop_size["height"],
                  self.image_processor_tester.crop_size["width"],
              )			,   )

          # Test batched
          lowerCamelCase__				   =      image_processing(UpperCamelCase			,   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.crop_size["height"],
                  self.image_processor_tester.crop_size["width"],
              )			,   )







   def     __UpperCAmelCase      ( self):
          # Initialize image_processing
          lowerCamelCase__				   =      self.image_processing_class(**self.image_processor_dict)
          # create random numpy tensors
          lowerCamelCase__				   =      self.image_processor_tester.prepare_inputs(equal_resolution=UpperCamelCase			,   numpify=UpperCamelCase)
          for image in image_inputs:
                 self.assertIsInstance(UpperCamelCase			,   np.ndarray)

          # Test not batched input
          lowerCamelCase__				   =      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.crop_size["height"],
                  self.image_processor_tester.crop_size["width"],
              )			,   )

          # Test batched
          lowerCamelCase__				   =      image_processing(UpperCamelCase			,   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.crop_size["height"],
                  self.image_processor_tester.crop_size["width"],
              )			,   )







   def     __UpperCAmelCase      ( self):
          # Initialize image_processing
          lowerCamelCase__				   =      self.image_processing_class(**self.image_processor_dict)
          # create random PyTorch tensors
          lowerCamelCase__				   =      self.image_processor_tester.prepare_inputs(equal_resolution=UpperCamelCase			,   torchify=UpperCamelCase)
          for image in image_inputs:
                 self.assertIsInstance(UpperCamelCase			,   torch.Tensor)

          # Test not batched input
          lowerCamelCase__				   =      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.crop_size["height"],
                  self.image_processor_tester.crop_size["width"],
              )			,   )

          # Test batched
          lowerCamelCase__				   =      image_processing(UpperCamelCase			,   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.crop_size["height"],
                  self.image_processor_tester.crop_size["width"],
              )			,   )







@require_torch
@require_vision
class 		snake_case_       (						A__		,	unittest.TestCase						):



   """simple docstring"""





   __lowerCAmelCase	:							Optional[Any]								=CLIPImageProcessor if is_vision_available() else None







   def     __UpperCAmelCase      ( self):
          lowerCamelCase__				   =      CLIPImageProcessingTester(self			,   num_channels=4)
          lowerCamelCase__				   =      3







   @property
   def     __UpperCAmelCase      ( self):
          return self.image_processor_tester.prepare_image_processor_dict()







   def     __UpperCAmelCase      ( self):
          lowerCamelCase__				   =      self.image_processing_class(**self.image_processor_dict)
          self.assertTrue(hasattr(UpperCamelCase			,   "do_resize"))
          self.assertTrue(hasattr(UpperCamelCase			,   "size"))
          self.assertTrue(hasattr(UpperCamelCase			,   "do_center_crop"))
          self.assertTrue(hasattr(UpperCamelCase			,   "center_crop"))
          self.assertTrue(hasattr(UpperCamelCase			,   "do_normalize"))
          self.assertTrue(hasattr(UpperCamelCase			,   "image_mean"))
          self.assertTrue(hasattr(UpperCamelCase			,   "image_std"))
          self.assertTrue(hasattr(UpperCamelCase			,   "do_convert_rgb"))







   def     __UpperCAmelCase      ( self):
          pass







   def     __UpperCAmelCase      ( self):
          # Initialize image_processing
          lowerCamelCase__				   =      self.image_processing_class(**self.image_processor_dict)
          # create random PIL images
          lowerCamelCase__				   =      self.image_processor_tester.prepare_inputs(equal_resolution=UpperCamelCase)
          for image in image_inputs:
                 self.assertIsInstance(UpperCamelCase			,   Image.Image)

          # Test not batched input
          lowerCamelCase__				   =      image_processing(image_inputs[0]			,   return_tensors="pt").pixel_values
          self.assertEqual(
              encoded_images.shape			,   (
                  1,
                  self.expected_encoded_image_num_channels,
                  self.image_processor_tester.crop_size["height"],
                  self.image_processor_tester.crop_size["width"],
              )			,   )

          # Test batched
          lowerCamelCase__				   =      image_processing(UpperCamelCase			,   return_tensors="pt").pixel_values
          self.assertEqual(
              encoded_images.shape			,   (
                  self.image_processor_tester.batch_size,
                  self.expected_encoded_image_num_channels,
                  self.image_processor_tester.crop_size["height"],
                  self.image_processor_tester.crop_size["width"],
              )			,   )



'''simple docstring'''







def   lowerCAmelCase(  a__    :  int = 1000      ):







       '''simple docstring'''






       lowerCamelCase__				   =      0
       for i in range(a__      ):
              if i % 3 == 0 or i % 5 == 0:
                     result += i
       return result


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

