code: 
  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       ):
  
  
  
  
  
  
  
  			def __init__(       self		,     _a		,     _a=7		,     _a=3		,     _a=18		,     _a=30		,     _a=400		,     _a=True		,     _a=None		,     _a=True		,     _a=None		,     _a=True		,     _a=[0.48_14_54_66, 0.4_57_82_75, 0.40_82_10_73]		,     _a=[0.26_86_29_54, 0.26_13_02_58, 0.27_57_77_11]		,     _a=True		,     ):
  				__magic_name__	:	str			     =  size if size is not None else {"shortest_edge": 20}
  				__magic_name__	:	int			     =  crop_size if crop_size is not None else {"height": 18, "width": 18}
  				__magic_name__	:	int			     =  parent
  				__magic_name__	:	List[Any]			     =  batch_size
  				__magic_name__	:	Optional[int]			     =  num_channels
  				__magic_name__	:	Any			     =  image_size
  				__magic_name__	:	Dict			     =  min_resolution
  				__magic_name__	:	Tuple			     =  max_resolution
  				__magic_name__	:	int			     =  do_resize
  				__magic_name__	:	Optional[Any]			     =  size
  				__magic_name__	:	int			     =  do_center_crop
  				__magic_name__	:	Union[str, Any]			     =  crop_size
  				__magic_name__	:	str			     =  do_normalize
  				__magic_name__	:	Tuple			     =  image_mean
  				__magic_name__	:	List[str]			     =  image_std
  				__magic_name__	:	Any			     =  do_convert_rgb
  
  
  
  
  
  
  
  			def     SCREAMING_SNAKE_CASE					(       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     SCREAMING_SNAKE_CASE					(       self		,     _a=False		,     _a=False		,     _a=False	):
  				assert not (numpify and torchify), "You cannot specify both numpy and PyTorch tensors at the same time"
  
  				if equal_resolution:
  					__magic_name__	:	Dict			     =  []
  					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:
  					__magic_name__	:	int			     =  []
  					for i in range(self.batch_size	):
  						__magic_name__     ,					__magic_name__	:	Tuple			     =  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
  					__magic_name__	:	Union[str, Any]			     =  [Image.fromarray(np.moveaxis(_a		,     0		,     -1	)	) for x in image_inputs]
  
  				if torchify:
  					__magic_name__	:	str			     =  [torch.from_numpy(_a	) for x in image_inputs]
  
  				return image_inputs
  
  
  
  
  
  
  
  @require_torch
  @require_vision
  class    _snake_case      (  snake_case       ,		unittest.TestCase       ):
  			UpperCamelCase__					   =					CLIPImageProcessor if is_vision_available() else None
  
  
  
  
  
  
  
  			def     SCREAMING_SNAKE_CASE					(       self	):
  				__magic_name__	:	Dict			     =  CLIPImageProcessingTester(self	)
  
  
  
  
  
  
  
  			@property
  			def     SCREAMING_SNAKE_CASE					(       self	):
  				return self.image_processor_tester.prepare_image_processor_dict()
  
  
  
  
  
  
  
  			def     SCREAMING_SNAKE_CASE					(       self	):
  				__magic_name__	:	Any			     =  self.image_processing_class(**self.image_processor_dict	)
  				self.assertTrue(hasattr(_a		,     "do_resize"	)	)
  				self.assertTrue(hasattr(_a		,     "size"	)	)
  				self.assertTrue(hasattr(_a		,     "do_center_crop"	)	)
  				self.assertTrue(hasattr(_a		,     "center_crop"	)	)
  				self.assertTrue(hasattr(_a		,     "do_normalize"	)	)
  				self.assertTrue(hasattr(_a		,     "image_mean"	)	)
  				self.assertTrue(hasattr(_a		,     "image_std"	)	)
  				self.assertTrue(hasattr(_a		,     "do_convert_rgb"	)	)
  
  
  
  
  
  
  
  			def     SCREAMING_SNAKE_CASE					(       self	):
  				__magic_name__	:	Union[str, Any]			     =  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}	)
  
  				__magic_name__	:	List[Any]			     =  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     SCREAMING_SNAKE_CASE					(       self	):
  				pass
  
  
  
  
  
  
  
  			def     SCREAMING_SNAKE_CASE					(       self	):
  				# Initialize image_processing
  				__magic_name__	:	List[str]			     =  self.image_processing_class(**self.image_processor_dict	)
  				# create random PIL images
  				__magic_name__	:	List[str]			     =  self.image_processor_tester.prepare_inputs(equal_resolution=_a	)
  				for image in image_inputs:
  					self.assertIsInstance(_a		,     Image.Image	)
  
  				# Test not batched input
  				__magic_name__	:	Tuple			     =  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
  				__magic_name__	:	List[Any]			     =  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.crop_size["height"],
  				        self.image_processor_tester.crop_size["width"],
  				    )		,     )
  
  
  
  
  
  
  
  			def     SCREAMING_SNAKE_CASE					(       self	):
  				# Initialize image_processing
  				__magic_name__	:	Optional[int]			     =  self.image_processing_class(**self.image_processor_dict	)
  				# create random numpy tensors
  				__magic_name__	:	int			     =  self.image_processor_tester.prepare_inputs(equal_resolution=_a		,     numpify=_a	)
  				for image in image_inputs:
  					self.assertIsInstance(_a		,     np.ndarray	)
  
  				# Test not batched input
  				__magic_name__	:	Optional[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.crop_size["height"],
  				        self.image_processor_tester.crop_size["width"],
  				    )		,     )
  
  				# Test batched
  				__magic_name__	:	Optional[int]			     =  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.crop_size["height"],
  				        self.image_processor_tester.crop_size["width"],
  				    )		,     )
  
  
  
  
  
  
  
  			def     SCREAMING_SNAKE_CASE					(       self	):
  				# Initialize image_processing
  				__magic_name__	:	str			     =  self.image_processing_class(**self.image_processor_dict	)
  				# create random PyTorch tensors
  				__magic_name__	:	str			     =  self.image_processor_tester.prepare_inputs(equal_resolution=_a		,     torchify=_a	)
  				for image in image_inputs:
  					self.assertIsInstance(_a		,     torch.Tensor	)
  
  				# Test not batched input
  				__magic_name__	:	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.crop_size["height"],
  				        self.image_processor_tester.crop_size["width"],
  				    )		,     )
  
  				# Test batched
  				__magic_name__	:	Tuple			     =  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.crop_size["height"],
  				        self.image_processor_tester.crop_size["width"],
  				    )		,     )
  
  
  
  
  
  
  
  @require_torch
  @require_vision
  class    _snake_case      (  snake_case       ,		unittest.TestCase       ):
  			UpperCamelCase__					   =					CLIPImageProcessor if is_vision_available() else None
  
  
  
  
  
  
  
  			def     SCREAMING_SNAKE_CASE					(       self	):
  				__magic_name__	:	List[str]			     =  CLIPImageProcessingTester(self		,     num_channels=4	)
  				__magic_name__	:	Any			     =  3
  
  
  
  
  
  
  
  			@property
  			def     SCREAMING_SNAKE_CASE					(       self	):
  				return self.image_processor_tester.prepare_image_processor_dict()
  
  
  
  
  
  
  
  			def     SCREAMING_SNAKE_CASE					(       self	):
  				__magic_name__	:	int			     =  self.image_processing_class(**self.image_processor_dict	)
  				self.assertTrue(hasattr(_a		,     "do_resize"	)	)
  				self.assertTrue(hasattr(_a		,     "size"	)	)
  				self.assertTrue(hasattr(_a		,     "do_center_crop"	)	)
  				self.assertTrue(hasattr(_a		,     "center_crop"	)	)
  				self.assertTrue(hasattr(_a		,     "do_normalize"	)	)
  				self.assertTrue(hasattr(_a		,     "image_mean"	)	)
  				self.assertTrue(hasattr(_a		,     "image_std"	)	)
  				self.assertTrue(hasattr(_a		,     "do_convert_rgb"	)	)
  
  
  
  
  
  
  
  			def     SCREAMING_SNAKE_CASE					(       self	):
  				pass
  
  
  
  
  
  
  
  			def     SCREAMING_SNAKE_CASE					(       self	):
  				# Initialize image_processing
  				__magic_name__	:	List[Any]			     =  self.image_processing_class(**self.image_processor_dict	)
  				# create random PIL images
  				__magic_name__	:	Optional[int]			     =  self.image_processor_tester.prepare_inputs(equal_resolution=_a	)
  				for image in image_inputs:
  					self.assertIsInstance(_a		,     Image.Image	)
  
  				# Test not batched input
  				__magic_name__	:	Optional[Any]			     =  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
  				__magic_name__	:	List[Any]			     =  image_processing(_a		,     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"],
  				    )		,     )
  
style_context: 
  def 						lowerCAmelCase_		(      _snake_case   :						int     )       ->	int:
  
  
  
  
  
  
  
  	'''simple docstring'''
  
  
  	if not isinstance(_snake_case   ,     _snake_case     ) or number < 0:
  		raise ValueError("Input must be a non-negative integer"     )
  
  	__magic_name__	:	Dict			     =  number & ~(number - 1)
  	__magic_name__	:	Optional[Any]			     =  0
  	while intermediate:
  		intermediate >>= 1
  		index += 1
  	return index - 1
  
  
  if __name__ == "__main__":
  				import doctest
  
  				doctest.testmod(verbose=True)
  