



"""simple docstring"""







from itertools import permutations

def    UpperCamelCase_		( lowerCamelCase_:       int = 5   ):
						"""simple docstring"""






						if gon_side < 3 or gon_side > 5:
												raise ValueError("gon_side must be in the range [3, 5]"   )

						# Since it's 16, we know 10 is on the outer ring
						# Put the big numbers at the end so that they are never the first number
						snake_case      : Tuple							=   list(range(gon_side + 1    ,		0    ,		-1   )   )
						snake_case      : Dict							=   list(range(gon_side + 2    ,		gon_side * 2 + 1   )   )

						for perm in permutations(small_numbers + big_numbers   ):
												snake_case      : List[Any]							=   generate_gon_ring(lowerCamelCase_    ,		list(lowerCamelCase_   )   )
												if is_magic_gon(lowerCamelCase_   ):
																		return int("".join(str(lowerCamelCase_   ) for n in numbers   )   )

						snake_case      : Optional[int]							=   f'''Magic {gon_side}-gon ring is impossible'''
						raise ValueError(lowerCamelCase_   )

def    UpperCamelCase_		( lowerCamelCase_:       int    ,		lowerCamelCase_:       list[int]   ):
						"""simple docstring"""






						snake_case      : Optional[int]							=   [0] * (gon_side * 3)
						snake_case      : Optional[int]							=   perm[0:3]
						perm.append(perm[1]   )

						snake_case      : Union[str, Any]							=   1 if gon_side < 5 else 2

						for i in range(1    ,		len(lowerCamelCase_   ) // 3 + magic_number   ):
												snake_case      : List[str]							=   perm[2 * i + 1]
												snake_case      : Any							=   result[3 * i - 1]
												snake_case      : Any							=   perm[2 * i + 2]

						return result

def    UpperCamelCase_		( lowerCamelCase_:       list[int]   ):
						"""simple docstring"""






						if len(lowerCamelCase_   ) % 3 != 0:
												raise ValueError("a gon ring should have a length that is a multiple of 3"   )

						if min(numbers[::3]   ) != numbers[0]:
												return False

						snake_case      : List[Any]							=   sum(numbers[:3]   )

						return all(sum(numbers[i : i + 3]   ) == total for i in range(3    ,		len(lowerCamelCase_   )    ,		3   )   )


if __name__ == "__main__":
			print(solution())








"""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, prepare_image_inputs


if is_torch_available():
			import torch

if is_vision_available():
			from PIL import Image

			from transformers import OwlViTImageProcessor

class 			_a     (   unittest.TestCase):



			def __init__( self       :							Optional[int]      ,  _lowercase       :							int      ,  _lowercase       :							Union[str, Any]=7      ,  _lowercase       :							Union[str, Any]=3      ,  _lowercase       :							int=18      ,  _lowercase       :							Any=30      ,  _lowercase       :							str=400      ,  _lowercase       :							str=True      ,  _lowercase       :							Dict=None      ,  _lowercase       :							int=True      ,  _lowercase       :							Union[str, Any]=None      ,  _lowercase       :							str=True      ,  _lowercase       :							Union[str, Any]=[0.48145466, 0.4578275, 0.40821073]      ,  _lowercase       :							str=[0.26862954, 0.26130258, 0.27577711]      ,  _lowercase       :							Optional[int]=True      ,  )       ->				Optional[int]:
									snake_case      : str							=   parent
									snake_case      : Any							=   batch_size
									snake_case      : Optional[int]							=   num_channels
									snake_case      : Any							=   image_size
									snake_case      : Optional[Any]							=   min_resolution
									snake_case      : int							=   max_resolution
									snake_case      : List[Any]							=   do_resize
									snake_case      : Dict							=   size if size is not None else {"height": 18, "width": 18}
									snake_case      : str							=   do_center_crop
									snake_case      : List[str]							=   crop_size if crop_size is not None else {"height": 18, "width": 18}
									snake_case      : str							=   do_normalize
									snake_case      : str							=   image_mean
									snake_case      : Optional[Any]							=   image_std
									snake_case      : str							=   do_convert_rgb



			def 							__lowercase				( self       :							Tuple		)       ->				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,
									}



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



			def 							__lowercase				( self       :							Any		)       ->				List[Any]:
									snake_case      : Dict							=   OwlViTImageProcessingTester(self		)



			@property
			def 							__lowercase				( self       :							Optional[int]		)       ->				List[Any]:
									return self.image_processor_tester.prepare_image_processor_dict()



			def 							__lowercase				( self       :							List[Any]		)       ->				Union[str, Any]:
									snake_case      : List[Any]							=   self.image_processing_class(**self.image_processor_dict		)
									self.assertTrue(hasattr(_lowercase      ,  "do_resize"		)		)
									self.assertTrue(hasattr(_lowercase      ,  "size"		)		)
									self.assertTrue(hasattr(_lowercase      ,  "do_center_crop"		)		)
									self.assertTrue(hasattr(_lowercase      ,  "center_crop"		)		)
									self.assertTrue(hasattr(_lowercase      ,  "do_normalize"		)		)
									self.assertTrue(hasattr(_lowercase      ,  "image_mean"		)		)
									self.assertTrue(hasattr(_lowercase      ,  "image_std"		)		)
									self.assertTrue(hasattr(_lowercase      ,  "do_convert_rgb"		)		)



			def 							__lowercase				( self       :							Any		)       ->				Any:
									snake_case      : List[Any]							=   self.image_processing_class.from_dict(self.image_processor_dict		)
									self.assertEqual(image_processor.size      ,  {"height": 18, "width": 18}		)
									self.assertEqual(image_processor.crop_size      ,  {"height": 18, "width": 18}		)

									snake_case      : int							=   self.image_processing_class.from_dict(self.image_processor_dict      ,  size=42      ,  crop_size=84		)
									self.assertEqual(image_processor.size      ,  {"height": 42, "width": 42}		)
									self.assertEqual(image_processor.crop_size      ,  {"height": 84, "width": 84}		)



			def 							__lowercase				( self       :							Any		)       ->				Optional[int]:
									# Initialize image_processing
									snake_case      : List[Any]							=   self.image_processing_class(**self.image_processor_dict		)
									# create random PIL images
									snake_case      : Tuple							=   prepare_image_inputs(self.image_processor_tester      ,  equal_resolution=_lowercase		)

									for image in image_inputs:
															self.assertIsInstance(_lowercase      ,  Image.Image		)

									# Test not batched input
									snake_case      : Dict							=   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
									snake_case      : Optional[Any]							=   image_processing(_lowercase      ,  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[Any]		)       ->				Dict:
									# Initialize image_processing
									snake_case      : Optional[int]							=   self.image_processing_class(**self.image_processor_dict		)
									# create random numpy tensors
									snake_case      : int							=   prepare_image_inputs(self.image_processor_tester      ,  equal_resolution=_lowercase      ,  numpify=_lowercase		)
									for image in image_inputs:
															self.assertIsInstance(_lowercase      ,  np.ndarray		)

									# Test not batched input
									snake_case      : str							=   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
									snake_case      : str							=   image_processing(_lowercase      ,  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       :							List[Any]		)       ->				List[str]:
									# Initialize image_processing
									snake_case      : Any							=   self.image_processing_class(**self.image_processor_dict		)
									# create random PyTorch tensors
									snake_case      : Dict							=   prepare_image_inputs(self.image_processor_tester      ,  equal_resolution=_lowercase      ,  torchify=_lowercase		)
									for image in image_inputs:
															self.assertIsInstance(_lowercase      ,  torch.Tensor		)

									# Test not batched input
									snake_case      : 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
									snake_case      : Any							=   image_processing(_lowercase      ,  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"],
									    )      ,  )



