






'''simple docstring'''




import unittest

import numpy as np

from transformers.file_utils import is_torch_available, is_vision_available
from transformers.testing_utils import require_torch, require_vision

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 DPTImageProcessor







class    A_	(unittest.TestCase							):
							"""simple docstring"""




							def __init__(		self			:Union[str, Any]       ,							lowerCAmelCase__			:Dict       ,							lowerCAmelCase__			:Optional[int]=7       ,							lowerCAmelCase__			:Union[str, Any]=3       ,							lowerCAmelCase__			:int=18       ,							lowerCAmelCase__			:List[str]=30       ,							lowerCAmelCase__			:List[str]=400       ,							lowerCAmelCase__			:Optional[int]=True       ,							lowerCAmelCase__			:List[str]=None       ,							lowerCAmelCase__			:Tuple=True       ,							lowerCAmelCase__			:Optional[int]=[0.5, 0.5, 0.5]       ,							lowerCAmelCase__			:str=[0.5, 0.5, 0.5]       ,							)				->  Optional[int]:


										'''simple docstring'''




										snake_case_				:					List[str]   =       size if size is not None else {"height": 18, "width": 18}
										snake_case_				:					List[str]   =       parent
										snake_case_				:					Union[str, Any]   =       batch_size
										snake_case_				:					Optional[Any]   =       num_channels
										snake_case_				:					List[str]   =       image_size
										snake_case_				:					int   =       min_resolution
										snake_case_				:					Optional[Any]   =       max_resolution
										snake_case_				:					List[str]   =       do_resize
										snake_case_				:					int   =       size
										snake_case_				:					List[Any]   =       do_normalize
										snake_case_				:					List[Any]   =       image_mean
										snake_case_				:					List[Any]   =       image_std






							def 							_A	(		self			:Optional[Any]				)				->  str:


										'''simple docstring'''




										return {
										    "image_mean": self.image_mean,
										    "image_std": self.image_std,
										    "do_normalize": self.do_normalize,
										    "do_resize": self.do_resize,
										    "size": self.size,
										}







@require_torch
@require_vision
class    A_	(a_						,					unittest.TestCase							):
							"""simple docstring"""




							a__   		=	DPTImageProcessor if is_vision_available() else None

							def 							_A	(		self			:Optional[Any]				)				->  Optional[int]:


										'''simple docstring'''




										snake_case_				:					str   =       DPTImageProcessingTester(self				)

							@property
							def 							_A	(		self			:Union[str, Any]				)				->  Optional[Any]:


										'''simple docstring'''




										return self.image_processor_tester.prepare_image_processor_dict()

							def 							_A	(		self			:int				)				->  Dict:


										'''simple docstring'''




										snake_case_				:					Tuple   =       self.image_processing_class(**self.image_processor_dict				)
										self.assertTrue(hasattr(lowerCAmelCase__       ,							"image_mean"				)				)
										self.assertTrue(hasattr(lowerCAmelCase__       ,							"image_std"				)				)
										self.assertTrue(hasattr(lowerCAmelCase__       ,							"do_normalize"				)				)
										self.assertTrue(hasattr(lowerCAmelCase__       ,							"do_resize"				)				)
										self.assertTrue(hasattr(lowerCAmelCase__       ,							"size"				)				)

							def 							_A	(		self			:List[Any]				)				->  List[str]:


										'''simple docstring'''




										snake_case_				:					List[str]   =       self.image_processing_class.from_dict(self.image_processor_dict				)
										self.assertEqual(image_processor.size       ,							{"height": 18, "width": 18}				)

										snake_case_				:					Optional[int]   =       self.image_processing_class.from_dict(self.image_processor_dict       ,							size=42				)
										self.assertEqual(image_processor.size       ,							{"height": 42, "width": 42}				)

							def 							_A	(		self			:Any				)				->  Optional[int]:


										'''simple docstring'''




										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=lowerCAmelCase__				)
										for image in image_inputs:
													self.assertIsInstance(lowerCAmelCase__       ,							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.size["height"],
										        self.image_processor_tester.size["width"],
										    )       ,							)

										# Test batched
										snake_case_				:					Optional[int]   =       image_processing(lowerCAmelCase__       ,							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.size["height"],
										        self.image_processor_tester.size["width"],
										    )       ,							)

							def 							_A	(		self			:Optional[Any]				)				->  Any:


										'''simple docstring'''




										snake_case_				:					Any   =       self.image_processing_class(**self.image_processor_dict				)
										# create random numpy tensors
										snake_case_				:					Union[str, Any]   =       prepare_image_inputs(self.image_processor_tester       ,							equal_resolution=lowerCAmelCase__       ,							numpify=lowerCAmelCase__				)
										for image in image_inputs:
													self.assertIsInstance(lowerCAmelCase__       ,							np.ndarray				)

										# Test not batched input
										snake_case_				:					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.size["height"],
										        self.image_processor_tester.size["width"],
										    )       ,							)

										# Test batched
										snake_case_				:					Any   =       image_processing(lowerCAmelCase__       ,							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.size["height"],
										        self.image_processor_tester.size["width"],
										    )       ,							)






							def 							_A	(		self			:List[Any]				)				->  int:


										'''simple docstring'''




										snake_case_				:					Tuple   =       self.image_processing_class(**self.image_processor_dict				)
										# create random PyTorch tensors
										snake_case_				:					List[str]   =       prepare_image_inputs(self.image_processor_tester       ,							equal_resolution=lowerCAmelCase__       ,							torchify=lowerCAmelCase__				)
										for image in image_inputs:
													self.assertIsInstance(lowerCAmelCase__       ,							torch.Tensor				)

										# Test not batched input
										snake_case_				:					List[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.size["height"],
										        self.image_processor_tester.size["width"],
										    )       ,							)

										# Test batched
										snake_case_				:					Union[str, Any]   =       image_processing(lowerCAmelCase__       ,							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.size["height"],
										        self.image_processor_tester.size["width"],
										    )       ,							)












'''simple docstring'''




def 	__UpperCAmelCase       ( __magic_name__						)->    list[int]:



			"""simple docstring"""



			if length <= 0 or not isinstance(__magic_name__     ,__magic_name__						):
						raise ValueError("Length must be a positive integer."						)
			return [n * (2 * n - 1) for n in range(__magic_name__						)]


if __name__ == "__main__":
		print(hexagonal_numbers(length=5))
		print(hexagonal_numbers(length=10))




