



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



			def __init__(		self  :    Any					,						A  :    List[Any]					,						A  :    int=7					,						A  :    str=3					,						A  :    Dict=30					,						A  :    Tuple=4_00					,						A  :    str=True					,						A  :    List[str]=None					,						A  :    Optional[Any]=True					,						A  :    Optional[int]=[0.5, 0.5, 0.5]					,						A  :    Tuple=[0.5, 0.5, 0.5]					,						A  :    List[Any]=False					,						)  ->       Optional[Any]:



						"""simple docstring"""






						_UpperCAmelCase									=  size if size is not None else {'height': 30, 'width': 30}
						_UpperCAmelCase									=  parent
						_UpperCAmelCase									=  batch_size
						_UpperCAmelCase									=  num_channels
						_UpperCAmelCase									=  min_resolution
						_UpperCAmelCase									=  max_resolution
						_UpperCAmelCase									=  do_resize
						_UpperCAmelCase									=  size
						_UpperCAmelCase									=  do_normalize
						_UpperCAmelCase									=  image_mean
						_UpperCAmelCase									=  image_std
						_UpperCAmelCase									=  do_reduce_labels



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



						"""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[int]:







			'''simple docstring'''
			_UpperCAmelCase									=  load_dataset('hf-internal-testing/fixtures_ade20k'				,  split='test'       )

			_UpperCAmelCase									=  Image.open(dataset[0]['file']       )
			_UpperCAmelCase									=  Image.open(dataset[1]['file']       )

			return image, map





def 				A      (	)							->					Any:







			'''simple docstring'''
			_UpperCAmelCase									=  load_dataset('hf-internal-testing/fixtures_ade20k'				,  split='test'       )

			_UpperCAmelCase									=  Image.open(dataset[0]['file']       )
			_UpperCAmelCase									=  Image.open(dataset[1]['file']       )
			_UpperCAmelCase									=  Image.open(dataset[2]['file']       )
			_UpperCAmelCase									=  Image.open(dataset[3]['file']       )

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







@require_torch
@require_vision
class      __lowerCAmelCase       (     A							,		unittest.TestCase		):
			UpperCamelCase     =	SegformerImageProcessor if is_vision_available() else None



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



						"""simple docstring"""






						_UpperCAmelCase									=  SegformerImageProcessingTester(self)



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



						"""simple docstring"""






						return self.image_processor_tester.prepare_image_processor_dict()



			def        _lowerCamelCase			(		self  :    int)  ->       Dict:



						"""simple docstring"""






						_UpperCAmelCase									=  self.image_processing_class(**self.image_processor_dict)
						self.assertTrue(hasattr(A					,						'do_resize'))
						self.assertTrue(hasattr(A					,						'size'))
						self.assertTrue(hasattr(A					,						'do_normalize'))
						self.assertTrue(hasattr(A					,						'image_mean'))
						self.assertTrue(hasattr(A					,						'image_std'))
						self.assertTrue(hasattr(A					,						'do_reduce_labels'))



			def        _lowerCamelCase			(		self  :    List[str])  ->       List[str]:



						"""simple docstring"""






						_UpperCAmelCase									=  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					,						A)

						_UpperCAmelCase									=  self.image_processing_class.from_dict(self.image_processor_dict					,						size=42					,						reduce_labels=A)
						self.assertEqual(image_processor.size					,						{'height': 42, 'width': 42})
						self.assertEqual(image_processor.do_reduce_labels					,						A)



			def        _lowerCamelCase			(		self  :    Dict)  ->       int:



						"""simple docstring"""






						pass



			def        _lowerCamelCase			(		self  :    int)  ->       str:



						"""simple docstring"""






						_UpperCAmelCase									=  self.image_processing_class(**self.image_processor_dict)
						# create random PIL images
						_UpperCAmelCase									=  prepare_image_inputs(self.image_processor_tester					,						equal_resolution=A)
						for image in image_inputs:
									self.assertIsInstance(A					,						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.size['height'],
						        self.image_processor_tester.size['width'],
						    )					,						)

						# Test batched
						_UpperCAmelCase									=  image_processing(A					,						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        _lowerCamelCase			(		self  :    Any)  ->       Tuple:



						"""simple docstring"""






						_UpperCAmelCase									=  self.image_processing_class(**self.image_processor_dict)
						# create random numpy tensors
						_UpperCAmelCase									=  prepare_image_inputs(self.image_processor_tester					,						equal_resolution=A					,						numpify=A)
						for image in image_inputs:
									self.assertIsInstance(A					,						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.size['height'],
						        self.image_processor_tester.size['width'],
						    )					,						)

						# Test batched
						_UpperCAmelCase									=  image_processing(A					,						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        _lowerCamelCase			(		self  :    str)  ->       int:



						"""simple docstring"""






						_UpperCAmelCase									=  self.image_processing_class(**self.image_processor_dict)
						# create random PyTorch tensors
						_UpperCAmelCase									=  prepare_image_inputs(self.image_processor_tester					,						equal_resolution=A					,						torchify=A)
						for image in image_inputs:
									self.assertIsInstance(A					,						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.size['height'],
						        self.image_processor_tester.size['width'],
						    )					,						)

						# Test batched
						_UpperCAmelCase									=  image_processing(A					,						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        _lowerCamelCase			(		self  :    Optional[Any])  ->       Union[str, Any]:



						"""simple docstring"""






						_UpperCAmelCase									=  self.image_processing_class(**self.image_processor_dict)
						# create random PyTorch tensors
						_UpperCAmelCase									=  prepare_image_inputs(self.image_processor_tester					,						equal_resolution=A					,						torchify=A)
						_UpperCAmelCase									=  []
						for image in image_inputs:
									self.assertIsInstance(A					,						torch.Tensor)
									maps.append(torch.zeros(image.shape[-2:]).long())

						# Test not batched input
						_UpperCAmelCase									=  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() <= 2_55)

						# Test batched
						_UpperCAmelCase									=  image_processing(A					,						A					,						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() <= 2_55)

						# Test not batched input (PIL images)
						_UpperCAmelCase			,	_UpperCAmelCase									=  prepare_semantic_single_inputs()

						_UpperCAmelCase									=  image_processing(A					,						A					,						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() <= 2_55)

						# Test batched input (PIL images)
						_UpperCAmelCase			,	_UpperCAmelCase									=  prepare_semantic_batch_inputs()

						_UpperCAmelCase									=  image_processing(A					,						A					,						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() <= 2_55)



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



						"""simple docstring"""






						_UpperCAmelCase									=  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
						_UpperCAmelCase			,	_UpperCAmelCase									=  prepare_semantic_single_inputs()
						_UpperCAmelCase									=  image_processing(A					,						A					,						return_tensors='pt')
						self.assertTrue(encoding['labels'].min().item() >= 0)
						self.assertTrue(encoding['labels'].max().item() <= 1_50)

						_UpperCAmelCase									=  True
						_UpperCAmelCase									=  image_processing(A					,						A					,						return_tensors='pt')
						self.assertTrue(encoding['labels'].min().item() >= 0)
						self.assertTrue(encoding['labels'].max().item() <= 2_55)





UpperCAmelCase__  =			10**8





def 				A      (	_UpperCAmelCase							:  int       )							->					bool:







			'''simple docstring'''
			if n % 10 == 0:
						return False
			_UpperCAmelCase									=  str(_UpperCAmelCase       )
			return s == s[::-1]





def 				A      (	)							->					int:







			'''simple docstring'''
			_UpperCAmelCase									=  set()
			_UpperCAmelCase									=  1
			_UpperCAmelCase									=  5
			while sum_squares < LIMIT:
						_UpperCAmelCase									=  first_square + 1
						while sum_squares < LIMIT:
									if is_palindrome(_UpperCAmelCase       ):
												answer.add(_UpperCAmelCase       )
									last_square += 1
									sum_squares += last_square**2
						first_square += 1
						_UpperCAmelCase									=  first_square**2 + (first_square + 1) ** 2

			return sum(_UpperCAmelCase       )


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