






import unittest

import numpy as np
from datasets import load_dataset

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 SegformerImageProcessor




class        snake_case_					(						unittest.TestCase			):

						"""simple docstring"""



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




											'''simple docstring'''



											__a				:	Any			=				size if size is not None else {"height": 30, "width": 30}
											__a				:	str			=				parent
											__a				:	List[str]			=				batch_size
											__a				:	int			=				num_channels
											__a				:	Union[str, Any]			=				min_resolution
											__a				:	Tuple			=				max_resolution
											__a				:	Tuple			=				do_resize
											__a				:	int			=				size
											__a				:	int			=				do_normalize
											__a				:	Any			=				image_mean
											__a				:	Dict			=				image_std
											__a				:	Dict			=				do_reduce_labels



						def 					UpperCAmelCase__				(self:				Union[str, Any]      )						->    List[str]:




											'''simple docstring'''



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







def 						a_      ()							->	Optional[Any]:



					"""simple docstring"""
					__a				:	str			=				load_dataset("hf-internal-testing/fixtures_ade20k"							,					split="test"			)

					__a				:	Tuple			=				Image.open(dataset[0]["file"]			)
					__a				:	Optional[int]			=				Image.open(dataset[1]["file"]			)

					return image, map







def 						a_      ()							->	Dict:



					"""simple docstring"""
					__a				:	Any			=				load_dataset("hf-internal-testing/fixtures_ade20k"							,					split="test"			)

					__a				:	Dict			=				Image.open(dataset[0]["file"]			)
					__a				:	List[Any]			=				Image.open(dataset[1]["file"]			)
					__a				:	List[str]			=				Image.open(dataset[2]["file"]			)
					__a				:	Optional[int]			=				Image.open(dataset[3]["file"]			)

					return [imagea, imagea], [mapa, mapa]




@require_torch
@require_vision
class        snake_case_					(						__UpperCamelCase		,       unittest.TestCase			):

						"""simple docstring"""



						snake_case__   					=			SegformerImageProcessor if is_vision_available() else None



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




											'''simple docstring'''



											__a				:	str			=				SegformerImageProcessingTester(self      )



						@property
						def 					UpperCAmelCase__				(self:				List[Any]      )						->    int:




											'''simple docstring'''



											return self.image_processor_tester.prepare_image_processor_dict()



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




											'''simple docstring'''



											__a				:	Tuple			=				self.image_processing_class(**self.image_processor_dict      )
											self.assertTrue(hasattr(__UpperCAmelCase   ,				"do_resize"      )      )
											self.assertTrue(hasattr(__UpperCAmelCase   ,				"size"      )      )
											self.assertTrue(hasattr(__UpperCAmelCase   ,				"do_normalize"      )      )
											self.assertTrue(hasattr(__UpperCAmelCase   ,				"image_mean"      )      )
											self.assertTrue(hasattr(__UpperCAmelCase   ,				"image_std"      )      )
											self.assertTrue(hasattr(__UpperCAmelCase   ,				"do_reduce_labels"      )      )



						def 					UpperCAmelCase__				(self:				Any      )						->    Dict:




											'''simple docstring'''



											__a				:	Optional[int]			=				self.image_processing_class.from_dict(self.image_processor_dict      )
											self.assertEqual(image_processor.size   ,				{"height": 30, "width": 30}      )
											self.assertEqual(image_processor.do_reduce_labels   ,				__UpperCAmelCase      )

											__a				:	List[Any]			=				self.image_processing_class.from_dict(self.image_processor_dict   ,				size=42   ,				reduce_labels=__UpperCAmelCase      )
											self.assertEqual(image_processor.size   ,				{"height": 42, "width": 42}      )
											self.assertEqual(image_processor.do_reduce_labels   ,				__UpperCAmelCase      )



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




											'''simple docstring'''



											pass



						def 					UpperCAmelCase__				(self:				Any      )						->    Dict:




											'''simple docstring'''



											__a				:	List[str]			=				self.image_processing_class(**self.image_processor_dict      )
											# create random PIL images
											__a				:	int			=				prepare_image_inputs(self.image_processor_tester   ,				equal_resolution=__UpperCAmelCase      )
											for image in image_inputs:
																self.assertIsInstance(__UpperCAmelCase   ,				Image.Image      )

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



						def 					UpperCAmelCase__				(self:				int      )						->    Tuple:




											'''simple docstring'''



											__a				:	Dict			=				self.image_processing_class(**self.image_processor_dict      )
											# create random numpy tensors
											__a				:	List[str]			=				prepare_image_inputs(self.image_processor_tester   ,				equal_resolution=__UpperCAmelCase   ,				numpify=__UpperCAmelCase      )
											for image in image_inputs:
																self.assertIsInstance(__UpperCAmelCase   ,				np.ndarray      )

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



						def 					UpperCAmelCase__				(self:				int      )						->    Optional[int]:




											'''simple docstring'''



											__a				:	Tuple			=				self.image_processing_class(**self.image_processor_dict      )
											# create random PyTorch tensors
											__a				:	Union[str, Any]			=				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
											__a				:	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
											__a				:	List[str]			=				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.size["height"],
											        self.image_processor_tester.size["width"],
											    )   ,				)



						def 					UpperCAmelCase__				(self:				Optional[int]      )						->    Union[str, Any]:




											'''simple docstring'''



											__a				:	Optional[Any]			=				self.image_processing_class(**self.image_processor_dict      )
											# create random PyTorch tensors
											__a				:	List[str]			=				prepare_image_inputs(self.image_processor_tester   ,				equal_resolution=__UpperCAmelCase   ,				torchify=__UpperCAmelCase      )
											__a				:	Dict			=				[]
											for image in image_inputs:
																self.assertIsInstance(__UpperCAmelCase   ,				torch.Tensor      )
																maps.append(torch.zeros(image.shape[-2:]      ).long()      )

											# Test not batched input
											__a				:	List[str]			=				image_processing(image_inputs[0]   ,				maps[0]   ,				return_tensors="pt"      )
											self.assertEqual(
											    encoding["pixel_values"].shape   ,				(
											        1,
											        self.image_processor_tester.num_channels,
											        self.image_processor_tester.size["height"],
											        self.image_processor_tester.size["width"],
											    )   ,				)
											self.assertEqual(
											    encoding["labels"].shape   ,				(
											        1,
											        self.image_processor_tester.size["height"],
											        self.image_processor_tester.size["width"],
											    )   ,				)
											self.assertEqual(encoding["labels"].dtype   ,				torch.long      )
											self.assertTrue(encoding["labels"].min().item() >= 0      )
											self.assertTrue(encoding["labels"].max().item() <= 255      )

											# Test batched
											__a				:	Tuple			=				image_processing(__UpperCAmelCase   ,				__UpperCAmelCase   ,				return_tensors="pt"      )
											self.assertEqual(
											    encoding["pixel_values"].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"],
											    )   ,				)
											self.assertEqual(
											    encoding["labels"].shape   ,				(
											        self.image_processor_tester.batch_size,
											        self.image_processor_tester.size["height"],
											        self.image_processor_tester.size["width"],
											    )   ,				)
											self.assertEqual(encoding["labels"].dtype   ,				torch.long      )
											self.assertTrue(encoding["labels"].min().item() >= 0      )
											self.assertTrue(encoding["labels"].max().item() <= 255      )

											# Test not batched input (PIL images)
											__a				:	str			=				prepare_semantic_single_inputs()

											__a				:	Any			=				image_processing(__UpperCAmelCase   ,				__UpperCAmelCase   ,				return_tensors="pt"      )
											self.assertEqual(
											    encoding["pixel_values"].shape   ,				(
											        1,
											        self.image_processor_tester.num_channels,
											        self.image_processor_tester.size["height"],
											        self.image_processor_tester.size["width"],
											    )   ,				)
											self.assertEqual(
											    encoding["labels"].shape   ,				(
											        1,
											        self.image_processor_tester.size["height"],
											        self.image_processor_tester.size["width"],
											    )   ,				)
											self.assertEqual(encoding["labels"].dtype   ,				torch.long      )
											self.assertTrue(encoding["labels"].min().item() >= 0      )
											self.assertTrue(encoding["labels"].max().item() <= 255      )

											# Test batched input (PIL images)
											__a				:	Union[str, Any]			=				prepare_semantic_batch_inputs()

											__a				:	List[Any]			=				image_processing(__UpperCAmelCase   ,				__UpperCAmelCase   ,				return_tensors="pt"      )
											self.assertEqual(
											    encoding["pixel_values"].shape   ,				(
											        2,
											        self.image_processor_tester.num_channels,
											        self.image_processor_tester.size["height"],
											        self.image_processor_tester.size["width"],
											    )   ,				)
											self.assertEqual(
											    encoding["labels"].shape   ,				(
											        2,
											        self.image_processor_tester.size["height"],
											        self.image_processor_tester.size["width"],
											    )   ,				)
											self.assertEqual(encoding["labels"].dtype   ,				torch.long      )
											self.assertTrue(encoding["labels"].min().item() >= 0      )
											self.assertTrue(encoding["labels"].max().item() <= 255      )



						def 					UpperCAmelCase__				(self:				List[Any]      )						->    Tuple:




											'''simple docstring'''



											__a				:	Optional[int]			=				self.image_processing_class(**self.image_processor_dict      )

											# ADE20k has 150 classes, and the background is included, so labels should be between 0 and 150
											__a				:	Dict			=				prepare_semantic_single_inputs()
											__a				:	List[Any]			=				image_processing(__UpperCAmelCase   ,				__UpperCAmelCase   ,				return_tensors="pt"      )
											self.assertTrue(encoding["labels"].min().item() >= 0      )
											self.assertTrue(encoding["labels"].max().item() <= 150      )

											__a				:	Any			=				True
											__a				:	Tuple			=				image_processing(__UpperCAmelCase   ,				__UpperCAmelCase   ,				return_tensors="pt"      )
											self.assertTrue(encoding["labels"].min().item() >= 0      )
											self.assertTrue(encoding["labels"].max().item() <= 255      )












import math







def 						a_      (__A			)							->	bool:



					"""simple docstring"""

					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(__A			) + 1			)							,					6			):
										if number % i == 0 or number % (i + 2) == 0:
															return False
					return True







def 						a_      (__A = 1_000							,					__A = 1_000			)							->	int:



					"""simple docstring"""
					__a				:	Optional[int]			=				[0, 0, 0]  # length, a, b
					for a in range((a_limit * -1) + 1							,					__A			):
										for b in range(2							,					__A			):
															if is_prime(__A			):
																				__a				:	Any			=				0
																				__a				:	List[str]			=				0
																				while is_prime((n**2) + (a * n) + b			):
																									count += 1
																									n += 1
																				if count > longest[0]:
																									__a				:	Any			=				[count, a, b]
					__a				:	str			=				longest[1] * longest[2]
					return ans


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





