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

					def __init__(	self					:     Dict   ,					__UpperCamelCase					:     List[str]   ,					__UpperCamelCase					:     Optional[Any]=7   ,					__UpperCamelCase					:     Optional[int]=3   ,					__UpperCamelCase					:     Any=1_8   ,					__UpperCamelCase					:     Optional[Any]=3_0   ,					__UpperCamelCase					:     Optional[Any]=4_0_0   ,					__UpperCamelCase					:     Union[str, Any]=True   ,					__UpperCamelCase					:     Optional[Any]=None   ,					__UpperCamelCase					:     str=True   ,					__UpperCamelCase					:     Tuple=None   ,					__UpperCamelCase					:     Optional[Any]=True   ,					__UpperCamelCase					:     str=[0.48145466, 0.4578275, 0.40821073]   ,					__UpperCamelCase					:     int=[0.26862954, 0.26130258, 0.27577711]   ,					__UpperCamelCase					:     int=True   ,					):
												lowerCamelCase_							  =					size if size is not None else {"""height""": 2_2_4, """width""": 2_2_4}
												lowerCamelCase_							  =					crop_size if crop_size is not None else {"""height""": 1_8, """width""": 1_8}
												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    lowercase__      (	self					:     Optional[int]   ):
												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    lowercase__      (	self					:     List[Any]   ,					__UpperCamelCase					:     List[Any]=False   ,					__UpperCamelCase					:     Dict=False   ,					__UpperCamelCase					:     List[Any]=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_5_5   ,					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_5_5   ,					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       __A(				UpperCAmelCase     ,		unittest.TestCase       ):
					SCREAMING_SNAKE_CASE			    =    ChineseCLIPImageProcessor if is_vision_available() else None

					def    lowercase__      (	self					:     List[Any]   ):
												lowerCamelCase_							  =					ChineseCLIPImageProcessingTester(self   ,					do_center_crop=__UpperCamelCase   )

					@property
					def    lowercase__      (	self					:     int   ):
												return self.image_processor_tester.prepare_image_processor_dict()

					def    lowercase__      (	self					:     Optional[Any]   ):
												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    lowercase__      (	self					:     Optional[int]   ):
												lowerCamelCase_							  =					self.image_processing_class.from_dict(self.image_processor_dict   )
												self.assertEqual(image_processor.size   ,					{"""height""": 2_2_4, """width""": 2_2_4}   )
												self.assertEqual(image_processor.crop_size   ,					{"""height""": 1_8, """width""": 1_8}   )

												lowerCamelCase_							  =					self.image_processing_class.from_dict(self.image_processor_dict   ,					size=4_2   ,					crop_size=8_4   )
												self.assertEqual(image_processor.size   ,					{"""shortest_edge""": 4_2}   )
												self.assertEqual(image_processor.crop_size   ,					{"""height""": 8_4, """width""": 8_4}   )

					def    lowercase__      (	self					:     Any   ):
												pass

					def    lowercase__      (	self					:     List[str]   ):
												# 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    lowercase__      (	self					:     str   ):
												# 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    lowercase__      (	self					:     Optional[int]   ):
												# 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       __A(				UpperCAmelCase     ,		unittest.TestCase       ):
					SCREAMING_SNAKE_CASE			    =    ChineseCLIPImageProcessor if is_vision_available() else None

					def    lowercase__      (	self					:     List[str]   ):
												lowerCamelCase_							  =					ChineseCLIPImageProcessingTester(self   ,					num_channels=4   ,					do_center_crop=__UpperCamelCase   )
												lowerCamelCase_							  =					3

					@property
					def    lowercase__      (	self					:     Optional[int]   ):
												return self.image_processor_tester.prepare_image_processor_dict()

					def    lowercase__      (	self					:     Dict   ):
												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    lowercase__      (	self					:     List[Any]   ):
												pass



					def    lowercase__      (	self					:     List[str]   ):
												# 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"""],
												    )   ,					)







def      __lowerCAmelCase						(							UpperCAmelCase__				:      int = 4_0_0_0_0_0_0       )  ->    int:
							lowerCamelCase_							  =					[]
							lowerCamelCase_  ,   lowerCamelCase_							  =					0, 1
							while b <= n:
														if b % 2 == 0:
																					even_fibs.append(UpperCAmelCase__       )
														lowerCamelCase_  ,   lowerCamelCase_							  =					b, a + b
							return sum(UpperCAmelCase__       )


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





