import unittest

import numpy as np
import requests

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

							from transformers.pytorch_utils import is_torch_greater_or_equal_than_1_11
else:
							_lowerCamelCase					:   List[str]							=		False

if is_vision_available():
							from PIL import Image

							from transformers import PixaStructImageProcessor


class 						lowercase    (     unittest.TestCase     ):




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



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       size if size is not None else {"height": 20, "width": 20}
												SCREAMING_SNAKE_CASE    			=       parent
												SCREAMING_SNAKE_CASE    			=       batch_size
												SCREAMING_SNAKE_CASE    			=       num_channels
												SCREAMING_SNAKE_CASE    			=       image_size
												SCREAMING_SNAKE_CASE    			=       min_resolution
												SCREAMING_SNAKE_CASE    			=       max_resolution
												SCREAMING_SNAKE_CASE    			=       size
												SCREAMING_SNAKE_CASE    			=       do_normalize
												SCREAMING_SNAKE_CASE    			=       do_convert_rgb
												SCREAMING_SNAKE_CASE    			=       [512, 1_024, 2_048, 4_096]
												SCREAMING_SNAKE_CASE    			=       patch_size if patch_size is not None else {"height": 16, "width": 16}




							def 	__snake_case(						self   :					List[Any]      )					->				List[Any]:



												'''simple docstring'''

												return {"do_normalize": self.do_normalize, "do_convert_rgb": self.do_convert_rgb}





							def 	__snake_case(						self   :					Union[str, Any]      )					->				Dict:



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/australia.jpg"
												SCREAMING_SNAKE_CASE    			=       Image.open(requests.get(_UpperCamelCase	,							stream=_UpperCamelCase      ).raw      ).convert("RGB"      )
												return raw_image



@unittest.skipIf(
    not is_torch_greater_or_equal_than_1_11				,       reason="""`Pix2StructImageProcessor` requires `torch>=1.11.0`."""				,       )
@require_torch
@require_vision
class 						lowercase    (     a				,       unittest.TestCase     ):
							lowercase__						:       str								=							PixaStructImageProcessor if is_vision_available() else None




							def 	__snake_case(						self   :					Optional[int]      )					->				List[str]:



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       PixaStructImageProcessingTester(self      )




							@property
							def 	__snake_case(						self   :					Optional[Any]      )					->				Optional[Any]:



												'''simple docstring'''

												return self.image_processor_tester.prepare_image_processor_dict()




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



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       self.image_processing_class(**self.image_processor_dict      )
												self.assertTrue(hasattr(_UpperCamelCase	,							"do_normalize"      )      )
												self.assertTrue(hasattr(_UpperCamelCase	,							"do_convert_rgb"      )      )




							def 	__snake_case(						self   :					Dict      )					->				int:



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       self.image_processor_tester.prepare_dummy_image()

												SCREAMING_SNAKE_CASE    			=       self.image_processing_class(**self.image_processor_dict      )
												SCREAMING_SNAKE_CASE    			=       2_048

												SCREAMING_SNAKE_CASE    			=       image_processor(_UpperCamelCase	,							return_tensors="pt"	,							max_patches=_UpperCamelCase      )
												self.assertTrue(torch.allclose(inputs.flattened_patches.mean()	,							torch.tensor(0.0_6_0_6      )	,							atol=1e-3	,							rtol=1e-3      )      )




							def 	__snake_case(						self   :					Tuple      )					->				str:



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       self.image_processing_class(**self.image_processor_dict      )
												# create random PIL images
												SCREAMING_SNAKE_CASE    			=       prepare_image_inputs(self.image_processor_tester	,							equal_resolution=_UpperCamelCase      )
												for image in image_inputs:
																	self.assertIsInstance(_UpperCamelCase	,							Image.Image      )

												# Test not batched input
												SCREAMING_SNAKE_CASE    			=       (
												    (self.image_processor_tester.patch_size["height"] * self.image_processor_tester.patch_size["width"])
												    * self.image_processor_tester.num_channels
												) + 2

												for max_patch in self.image_processor_tester.max_patches:
																	# Test not batched input
																	SCREAMING_SNAKE_CASE    			=       image_processor(
																	    image_inputs[0]	,							return_tensors="pt"	,							max_patches=_UpperCamelCase      ).flattened_patches
																	self.assertEqual(
																	    encoded_images.shape	,							(1, max_patch, expected_hidden_dim)	,							)

																	# Test batched
																	SCREAMING_SNAKE_CASE    			=       image_processor(
																	    _UpperCamelCase	,							return_tensors="pt"	,							max_patches=_UpperCamelCase      ).flattened_patches
																	self.assertEqual(
																	    encoded_images.shape	,							(self.image_processor_tester.batch_size, max_patch, expected_hidden_dim)	,							)




							def 	__snake_case(						self   :					int      )					->				int:



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       self.image_processing_class(**self.image_processor_dict      )
												# create random PIL images
												SCREAMING_SNAKE_CASE    			=       prepare_image_inputs(self.image_processor_tester	,							equal_resolution=_UpperCamelCase      )
												for image in image_inputs:
																	self.assertIsInstance(_UpperCamelCase	,							Image.Image      )

												# Test not batched input
												SCREAMING_SNAKE_CASE    			=       (
												    (self.image_processor_tester.patch_size["height"] * self.image_processor_tester.patch_size["width"])
												    * self.image_processor_tester.num_channels
												) + 2

												SCREAMING_SNAKE_CASE    			=       True

												for max_patch in self.image_processor_tester.max_patches:
																	# Test not batched input
																	with self.assertRaises(_UpperCamelCase      ):
																						SCREAMING_SNAKE_CASE    			=       image_processor(
																						    image_inputs[0]	,							return_tensors="pt"	,							max_patches=_UpperCamelCase      ).flattened_patches

																	SCREAMING_SNAKE_CASE    			=       "Hello"

																	SCREAMING_SNAKE_CASE    			=       image_processor(
																	    image_inputs[0]	,							return_tensors="pt"	,							max_patches=_UpperCamelCase	,							header_text=_UpperCamelCase      ).flattened_patches
																	self.assertEqual(
																	    encoded_images.shape	,							(1, max_patch, expected_hidden_dim)	,							)

																	# Test batched
																	SCREAMING_SNAKE_CASE    			=       image_processor(
																	    _UpperCamelCase	,							return_tensors="pt"	,							max_patches=_UpperCamelCase	,							header_text=_UpperCamelCase      ).flattened_patches
																	self.assertEqual(
																	    encoded_images.shape	,							(self.image_processor_tester.batch_size, max_patch, expected_hidden_dim)	,							)




							def 	__snake_case(						self   :					Dict      )					->				List[Any]:



												'''simple docstring'''

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

												SCREAMING_SNAKE_CASE    			=       (
												    (self.image_processor_tester.patch_size["height"] * self.image_processor_tester.patch_size["width"])
												    * self.image_processor_tester.num_channels
												) + 2

												for max_patch in self.image_processor_tester.max_patches:
																	# Test not batched input
																	SCREAMING_SNAKE_CASE    			=       image_processor(
																	    image_inputs[0]	,							return_tensors="pt"	,							max_patches=_UpperCamelCase      ).flattened_patches
																	self.assertEqual(
																	    encoded_images.shape	,							(1, max_patch, expected_hidden_dim)	,							)

																	# Test batched
																	SCREAMING_SNAKE_CASE    			=       image_processor(
																	    _UpperCamelCase	,							return_tensors="pt"	,							max_patches=_UpperCamelCase      ).flattened_patches
																	self.assertEqual(
																	    encoded_images.shape	,							(self.image_processor_tester.batch_size, max_patch, expected_hidden_dim)	,							)





							def 	__snake_case(						self   :					Optional[int]      )					->				Tuple:



												'''simple docstring'''

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

												# Test not batched input
												SCREAMING_SNAKE_CASE    			=       (
												    (self.image_processor_tester.patch_size["height"] * self.image_processor_tester.patch_size["width"])
												    * self.image_processor_tester.num_channels
												) + 2

												for max_patch in self.image_processor_tester.max_patches:
																	# Test not batched input
																	SCREAMING_SNAKE_CASE    			=       image_processor(
																	    image_inputs[0]	,							return_tensors="pt"	,							max_patches=_UpperCamelCase      ).flattened_patches
																	self.assertEqual(
																	    encoded_images.shape	,							(1, max_patch, expected_hidden_dim)	,							)

																	# Test batched
																	SCREAMING_SNAKE_CASE    			=       image_processor(
																	    _UpperCamelCase	,							return_tensors="pt"	,							max_patches=_UpperCamelCase      ).flattened_patches
																	self.assertEqual(
																	    encoded_images.shape	,							(self.image_processor_tester.batch_size, max_patch, expected_hidden_dim)	,							)



@unittest.skipIf(
    not is_torch_greater_or_equal_than_1_11				,       reason="""`Pix2StructImageProcessor` requires `torch>=1.11.0`."""				,       )
@require_torch
@require_vision
class 						lowercase    (     a				,       unittest.TestCase     ):
							lowercase__						:       Optional[Any]								=							PixaStructImageProcessor if is_vision_available() else None




							def 	__snake_case(						self   :					List[Any]      )					->				Any:



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       PixaStructImageProcessingTester(self	,							num_channels=4      )
												SCREAMING_SNAKE_CASE    			=       3




							@property
							def 	__snake_case(						self   :					str      )					->				int:



												'''simple docstring'''

												return self.image_processor_tester.prepare_image_processor_dict()




							def 	__snake_case(						self   :					Optional[Any]      )					->				Dict:



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       self.image_processing_class(**self.image_processor_dict      )
												self.assertTrue(hasattr(_UpperCamelCase	,							"do_normalize"      )      )
												self.assertTrue(hasattr(_UpperCamelCase	,							"do_convert_rgb"      )      )





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



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       self.image_processing_class(**self.image_processor_dict      )
												# create random PIL images
												SCREAMING_SNAKE_CASE    			=       prepare_image_inputs(self.image_processor_tester	,							equal_resolution=_UpperCamelCase      )
												for image in image_inputs:
																	self.assertIsInstance(_UpperCamelCase	,							Image.Image      )

												# Test not batched input
												SCREAMING_SNAKE_CASE    			=       (
												    (self.image_processor_tester.patch_size["height"] * self.image_processor_tester.patch_size["width"])
												    * (self.image_processor_tester.num_channels - 1)
												) + 2

												for max_patch in self.image_processor_tester.max_patches:
																	# Test not batched input
																	SCREAMING_SNAKE_CASE    			=       image_processor(
																	    image_inputs[0]	,							return_tensors="pt"	,							max_patches=_UpperCamelCase      ).flattened_patches
																	self.assertEqual(
																	    encoded_images.shape	,							(1, max_patch, expected_hidden_dim)	,							)

																	# Test batched
																	SCREAMING_SNAKE_CASE    			=       image_processor(
																	    _UpperCamelCase	,							return_tensors="pt"	,							max_patches=_UpperCamelCase      ).flattened_patches
																	self.assertEqual(
																	    encoded_images.shape	,							(self.image_processor_tester.batch_size, max_patch, expected_hidden_dim)	,							)





from __future__ import annotations

import math





def 	__lowerCamelCase							(UpperCAmelCase__     :							int  ):

					if 1 < number < 4:
										# 2 and 3 are primes
										return True
					elif number < 2 or number % 2 == 0 or number % 3 == 0:
										# Negatives, 0, 1, all even numbers, all multiples of 3 are not primes
										return False

					# All primes number are in format of 6k +/- 1
					for i in range(5      , int(math.sqrt(UpperCAmelCase__  ) + 1  )      , 6  ):
										if number % i == 0 or number % (i + 2) == 0:
															return False
					return True


_lowerCamelCase					:   Tuple							=		[num for num in range(3, 10_00_01, 2) if not is_prime(num)]





def 	__lowerCamelCase							(UpperCAmelCase__     :							int  ):
					if not isinstance(UpperCAmelCase__      , UpperCAmelCase__  ):
										raise ValueError("n must be an integer"  )
					if n <= 0:
										raise ValueError("n must be >= 0"  )

					SCREAMING_SNAKE_CASE    			=       []
					for num in range(len(UpperCAmelCase__  )  ):
										SCREAMING_SNAKE_CASE    			=       0
										while 2 * i * i <= odd_composites[num]:
															SCREAMING_SNAKE_CASE    			=       odd_composites[num] - 2 * i * i
															if is_prime(UpperCAmelCase__  ):
																				break
															i += 1
										else:
															list_nums.append(odd_composites[num]  )
															if len(UpperCAmelCase__  ) == n:
																				return list_nums

					return []





def 	__lowerCamelCase							():
					return compute_nums(1  )[0]


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




