


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







       def __init__(       self:      Any,A_:      Optional[int],A_:      Optional[Any]=7,A_:      Tuple=3,A_:      Optional[Any]=18,A_:      Any=30,A_:      Dict=400,A_:      Dict=True,A_:      Optional[Any]=None,A_:      Tuple=True,A_:      Tuple=None,A_:      Optional[Any]=True,A_:      str=[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],A_:      Optional[int]=[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],A_:      Optional[int]=True,):






            '''simple docstring'''




            __UpperCamelCase      =       size if size is not None else {'height': 224, 'width': 224}
            __UpperCamelCase      =       crop_size if crop_size is not None else {'height': 18, 'width': 18}
            __UpperCamelCase      =       parent
            __UpperCamelCase      =       batch_size
            __UpperCamelCase      =       num_channels
            __UpperCamelCase      =       image_size
            __UpperCamelCase      =       min_resolution
            __UpperCamelCase      =       max_resolution
            __UpperCamelCase      =       do_resize
            __UpperCamelCase      =       size
            __UpperCamelCase      =       do_center_crop
            __UpperCamelCase      =       crop_size
            __UpperCamelCase      =       do_normalize
            __UpperCamelCase      =       image_mean
            __UpperCamelCase      =       image_std
            __UpperCamelCase      =       do_convert_rgb







       def 						snake_case_     (       self:      Any ):






            '''simple docstring'''




            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 						snake_case_     (       self:      Optional[Any],A_:      Optional[int]=False,A_:      List[Any]=False,A_:      Dict=False ):






            '''simple docstring'''




            assert not (numpify and torchify), "You cannot specify both numpy and PyTorch tensors at the same time"

            if equal_resolution:
                 __UpperCamelCase      =       []
                 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:
                 __UpperCamelCase      =       []
                 for i in range(self.batch_size ):
                      __UpperCamelCase,  __UpperCamelCase      =       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
                 __UpperCamelCase      =       [Image.fromarray(np.moveaxis(SCREAMING_SNAKE_CASE_,0,-1 ) ) for x in image_inputs]

            if torchify:
                 __UpperCamelCase      =       [torch.from_numpy(SCREAMING_SNAKE_CASE_ ) for x in image_inputs]

            return image_inputs



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







       def 						snake_case_     (       self:      Union[str, Any] ):






            '''simple docstring'''




            __UpperCamelCase      =       ChineseCLIPImageProcessingTester(self,do_center_crop=SCREAMING_SNAKE_CASE_ )







       @property
       def 						snake_case_     (       self:      Any ):






            '''simple docstring'''




            return self.image_processor_tester.prepare_image_processor_dict()







       def 						snake_case_     (       self:      str ):






            '''simple docstring'''




            __UpperCamelCase      =       self.image_processing_class(**self.image_processor_dict )
            self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_,'do_resize' ) )
            self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_,'size' ) )
            self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_,'do_center_crop' ) )
            self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_,'center_crop' ) )
            self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_,'do_normalize' ) )
            self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_,'image_mean' ) )
            self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_,'image_std' ) )
            self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_,'do_convert_rgb' ) )







       def 						snake_case_     (       self:      int ):






            '''simple docstring'''




            __UpperCamelCase      =       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} )

            __UpperCamelCase      =       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 						snake_case_     (       self:      List[str] ):






            '''simple docstring'''




            pass







       def 						snake_case_     (       self:      List[Any] ):






            '''simple docstring'''




            __UpperCamelCase      =       self.image_processing_class(**self.image_processor_dict )
            # create random PIL images
            __UpperCamelCase      =       self.image_processor_tester.prepare_inputs(equal_resolution=SCREAMING_SNAKE_CASE_ )
            for image in image_inputs:
                 self.assertIsInstance(SCREAMING_SNAKE_CASE_,Image.Image )

            # Test not batched input
            __UpperCamelCase      =       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
            __UpperCamelCase      =       image_processing(SCREAMING_SNAKE_CASE_,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 						snake_case_     (       self:      int ):






            '''simple docstring'''




            __UpperCamelCase      =       self.image_processing_class(**self.image_processor_dict )
            # create random numpy tensors
            __UpperCamelCase      =       self.image_processor_tester.prepare_inputs(equal_resolution=SCREAMING_SNAKE_CASE_,numpify=SCREAMING_SNAKE_CASE_ )
            for image in image_inputs:
                 self.assertIsInstance(SCREAMING_SNAKE_CASE_,np.ndarray )

            # Test not batched input
            __UpperCamelCase      =       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
            __UpperCamelCase      =       image_processing(SCREAMING_SNAKE_CASE_,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 						snake_case_     (       self:      Union[str, Any] ):






            '''simple docstring'''




            __UpperCamelCase      =       self.image_processing_class(**self.image_processor_dict )
            # create random PyTorch tensors
            __UpperCamelCase      =       self.image_processor_tester.prepare_inputs(equal_resolution=SCREAMING_SNAKE_CASE_,torchify=SCREAMING_SNAKE_CASE_ )
            for image in image_inputs:
                 self.assertIsInstance(SCREAMING_SNAKE_CASE_,torch.Tensor )

            # Test not batched input
            __UpperCamelCase      =       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
            __UpperCamelCase      =       image_processing(SCREAMING_SNAKE_CASE_,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      __lowerCamelCase       (_a							,	unittest.TestCase		):
       _lowercase											=			ChineseCLIPImageProcessor if is_vision_available() else None







       def 						snake_case_     (       self:      int ):






            '''simple docstring'''




            __UpperCamelCase      =       ChineseCLIPImageProcessingTester(self,num_channels=4,do_center_crop=SCREAMING_SNAKE_CASE_ )
            __UpperCamelCase      =       3







       @property
       def 						snake_case_     (       self:      Optional[int] ):






            '''simple docstring'''




            return self.image_processor_tester.prepare_image_processor_dict()







       def 						snake_case_     (       self:      Optional[int] ):






            '''simple docstring'''




            __UpperCamelCase      =       self.image_processing_class(**self.image_processor_dict )
            self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_,'do_resize' ) )
            self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_,'size' ) )
            self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_,'do_center_crop' ) )
            self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_,'center_crop' ) )
            self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_,'do_normalize' ) )
            self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_,'image_mean' ) )
            self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_,'image_std' ) )
            self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_,'do_convert_rgb' ) )







       def 						snake_case_     (       self:      Dict ):






            '''simple docstring'''




            pass







       def 						snake_case_     (       self:      Optional[Any] ):






            '''simple docstring'''




            __UpperCamelCase      =       self.image_processing_class(**self.image_processor_dict )
            # create random PIL images
            __UpperCamelCase      =       self.image_processor_tester.prepare_inputs(equal_resolution=SCREAMING_SNAKE_CASE_ )
            for image in image_inputs:
                 self.assertIsInstance(SCREAMING_SNAKE_CASE_,Image.Image )

            # Test not batched input
            __UpperCamelCase      =       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
            __UpperCamelCase      =       image_processing(SCREAMING_SNAKE_CASE_,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 				a						(							snake_case__:					list					):


				'''simple docstring'''

				if len(snake_case__					) <= 1:
								return [tuple(snake_case__					)]

				lowercase_       =					[]

				def generate(snake_case__:					int						,   snake_case__:					list					):
								if k == 1:
												res.append(tuple(arr[:]					)					)
												return

								generate(k - 1						,   snake_case__					)

								for i in range(k - 1					):
												if k % 2 == 0:  # k is even
																lowercase_  ,	lowercase_       =					arr[k - 1], arr[i]
												else:  # k is odd
																lowercase_  ,	lowercase_       =					arr[k - 1], arr[0]
												generate(k - 1						,   snake_case__					)

				generate(len(snake_case__					)						,   snake_case__					)
				return res


if __name__ == "__main__":
						__a  			=					input('Enter numbers separated by a comma:\n').strip()
						__a  			=					[int(item) for item in user_input.split(',')]
						print(heaps(arr))




