




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





class    __lowercase						(  unittest.TestCase ):







   def __init__(	self      ,							UpperCamelCase      ,							UpperCamelCase=7      ,							UpperCamelCase=3      ,							UpperCamelCase=18      ,							UpperCamelCase=30      ,							UpperCamelCase=400      ,							UpperCamelCase=True      ,							UpperCamelCase=None      ,							UpperCamelCase=True      ,							UpperCamelCase=None      ,							UpperCamelCase=True      ,							UpperCamelCase=[0.48_145_466, 0.4_578_275, 0.40_821_073]      ,							UpperCamelCase=[0.26_862_954, 0.26_130_258, 0.27_577_711]      ,							UpperCamelCase=True      ,							)				->    int:
     __a			=					size if size is not None else {'height': 224, 'width': 224}
     __a			=					crop_size if crop_size is not None else {'height': 18, 'width': 18}
     __a			=					parent
     __a			=					batch_size
     __a			=					num_channels
     __a			=					image_size
     __a			=					min_resolution
     __a			=					max_resolution
     __a			=					do_resize
     __a			=					size
     __a			=					do_center_crop
     __a			=					crop_size
     __a			=					do_normalize
     __a			=					image_mean
     __a			=					image_std
     __a			=					do_convert_rgb







   def 		UpperCamelCase__			(	self      )				->    Union[str, Any]:
     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      )				->    int:
     assert not (numpify and torchify), "You cannot specify both numpy and PyTorch tensors at the same time"

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

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

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

     return image_inputs





@require_torch
@require_vision
class    __lowercase						(  __magic_name__       ,							unittest.TestCase ):
   _a							=      ChineseCLIPImageProcessor if is_vision_available() else None







   def 		UpperCamelCase__			(	self      )				->    Any:
     __a			=					ChineseCLIPImageProcessingTester(self      ,							do_center_crop=UpperCamelCase      )







   @property
   def 		UpperCamelCase__			(	self      )				->    int:
     return self.image_processor_tester.prepare_image_processor_dict()







   def 		UpperCamelCase__			(	self      )				->    str:
     __a			=					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      )				->    Optional[int]:
     __a			=					self.image_processing_class.from_dict(self.image_processor_dict      )
     self.assertEqual(image_processor.size      ,							{'height': 224, 'width': 224}      )
     self.assertEqual(image_processor.crop_size      ,							{'height': 18, 'width': 18}      )

     __a			=					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      )				->    Tuple:
     pass







   def 		UpperCamelCase__			(	self      )				->    Optional[int]:
     # Initialize image_processing
     __a			=					self.image_processing_class(**self.image_processor_dict      )
     # create random PIL images
     __a			=					self.image_processor_tester.prepare_inputs(equal_resolution=UpperCamelCase      )
     for image in image_inputs:
       self.assertIsInstance(UpperCamelCase      ,							Image.Image      )

     # Test not batched input
     __a			=					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
     __a			=					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      )				->    Tuple:
     # Initialize image_processing
     __a			=					self.image_processing_class(**self.image_processor_dict      )
     # create random numpy tensors
     __a			=					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
     __a			=					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
     __a			=					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      )				->    List[Any]:
     # Initialize image_processing
     __a			=					self.image_processing_class(**self.image_processor_dict      )
     # create random PyTorch tensors
     __a			=					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
     __a			=					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
     __a			=					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    __lowercase						(  __magic_name__       ,							unittest.TestCase ):
   _a							=      ChineseCLIPImageProcessor if is_vision_available() else None







   def 		UpperCamelCase__			(	self      )				->    Any:
     __a			=					ChineseCLIPImageProcessingTester(self      ,							num_channels=4      ,							do_center_crop=UpperCamelCase      )
     __a			=					3







   @property
   def 		UpperCamelCase__			(	self      )				->    Any:
     return self.image_processor_tester.prepare_image_processor_dict()







   def 		UpperCamelCase__			(	self      )				->    str:
     __a			=					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      )				->    List[Any]:
     pass







   def 		UpperCamelCase__			(	self      )				->    List[Any]:
     # Initialize image_processing
     __a			=					self.image_processing_class(**self.image_processor_dict      )
     # create random PIL images
     __a			=					self.image_processor_tester.prepare_inputs(equal_resolution=UpperCamelCase      )
     for image in image_inputs:
       self.assertIsInstance(UpperCamelCase      ,							Image.Image      )

     # Test not batched input
     __a			=					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
     __a			=					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 						SCREAMING_SNAKE_CASE       (      a_	:							int			):
  __a			=					0
  while num > 0:
    digit_sum += num % 10
    num //= 10
  return digit_sum


def 						SCREAMING_SNAKE_CASE       (      a_	:							int = 100			):
  __a			=					1
  __a			=					2

  for i in range(2				,					max_n + 1			):
    __a			=					pre_numerator
    __a			=					2 * i // 3 if i % 3 == 0 else 1
    __a			=					cur_numerator
    __a			=					e_cont * pre_numerator + temp

  return sum_digits(a_			)


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



