

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				):




      """simple docstring"""

      def __init__(   self							:				Tuple						,			UpperCAmelCase							:				Any						,			UpperCAmelCase							:				List[Any]=7						,			UpperCAmelCase							:				Optional[Any]=3						,			UpperCAmelCase							:				Union[str, Any]=18						,			UpperCAmelCase							:				Optional[Any]=30						,			UpperCAmelCase							:				Optional[Any]=400						,			UpperCAmelCase							:				Optional[int]=True						,			UpperCAmelCase							:				List[str]=None						,			UpperCAmelCase							:				Optional[int]=True						,			UpperCAmelCase							:				str=None						,			UpperCAmelCase							:				List[Any]=True						,			UpperCAmelCase							:				Tuple=[0.48_145_466, 0.4_578_275, 0.40_821_073]						,			UpperCAmelCase							:				str=[0.26_862_954, 0.26_130_258, 0.27_577_711]						,			UpperCAmelCase							:				int=True						,			):
            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 		__A	(   self							:				Tuple	):
            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 		__A	(   self							:				List[str]						,			UpperCAmelCase							:				Union[str, Any]=False						,			UpperCAmelCase							:				int=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:
                  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   _a					(			snake_case_     ,				unittest.TestCase				):




      """simple docstring"""

      _lowerCamelCase       :			List[Any]      		=       ChineseCLIPImageProcessor if is_vision_available() else None





      def 		__A	(   self							:				int	):
            A_						  =				ChineseCLIPImageProcessingTester(self						,			do_center_crop=UpperCAmelCase	)





      @property
      def 		__A	(   self							:				Dict	):
            return self.image_processor_tester.prepare_image_processor_dict()





      def 		__A	(   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 		__A	(   self							:				str	):
            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 		__A	(   self							:				str	):
            pass





      def 		__A	(   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 		__A	(   self							:				Optional[int]	):
            # 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 		__A	(   self							:				Optional[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   _a					(			snake_case_     ,				unittest.TestCase				):




      """simple docstring"""

      _lowerCamelCase       :			Union[str, Any]      		=       ChineseCLIPImageProcessor if is_vision_available() else None





      def 		__A	(   self							:				List[str]	):
            A_						  =				ChineseCLIPImageProcessingTester(self						,			num_channels=4						,			do_center_crop=UpperCAmelCase	)
            A_						  =				3





      @property
      def 		__A	(   self							:				List[str]	):
            return self.image_processor_tester.prepare_image_processor_dict()





      def 		__A	(   self							:				Optional[int]	):
            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 		__A	(   self							:				List[str]	):
            pass







      def 		__A	(   self							:				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"],
                )						,			)


def 			lowerCAmelCase(      SCREAMING_SNAKE_CASE_ = 4_0_0_0_0_0_0			)->						int:



    """simple docstring"""






    UpperCamelCase_			  =						[0, 1]
    UpperCamelCase_			  =						0
    while fib[i] <= n:
        fib.append(fib[i] + fib[i + 1]			)
        if fib[i + 2] > n:
            break
        i += 1
    UpperCamelCase_			  =						0
    for j in range(len(SCREAMING_SNAKE_CASE_			) - 1			):
        if fib[j] % 2 == 0:
            total += fib[j]

    return total


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