






"""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 ViltImageProcessor






class 						snake_case  (  unittest.TestCase       ):





    def __init__(							self	:					List[str]				,		A	:					Optional[int]				,		A	:					Union[str, Any]=7				,		A	:					str=3				,		A	:					Dict=1_8				,		A	:					Optional[int]=3_0				,		A	:					Tuple=4_0_0				,		A	:					str=True				,		A	:					Any=None				,		A	:					Dict=2				,		A	:					Union[str, Any]=True				,		A	:					List[Any]=[0.5, 0.5, 0.5]				,		A	:					Tuple=[0.5, 0.5, 0.5]				,		):


      '''simple docstring'''




      a     :			Tuple				=   size if size is not None else {'shortest_edge': 3_0}
      a     :			Optional[Any]				=   parent
      a     :			Union[str, Any]				=   batch_size
      a     :			Optional[Any]				=   num_channels
      a     :			List[str]				=   image_size
      a     :			Optional[Any]				=   min_resolution
      a     :			Union[str, Any]				=   max_resolution
      a     :			Tuple				=   do_resize
      a     :			Optional[int]				=   size
      a     :			Any				=   size_divisor
      a     :			str				=   do_normalize
      a     :			Tuple				=   image_mean
      a     :			Dict				=   image_std





    def 				lowerCamelCase__      (							self	:					Optional[Any]			):


      '''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,
          "size_divisor": self.size_divisor,
      }





    def 				lowerCamelCase__      (							self	:					Optional[int]				,		A	:					List[Any]				,		A	:					Optional[Any]=False			):


      '''simple docstring'''




      if not batched:
        a     :			List[Any]				=   self.size['shortest_edge']
        a     :			Dict				=   image_inputs[0]
        if isinstance(A				,		Image.Image			):
          a,     a     :			Union[str, Any]				=   image.size
        else:
          a,     a     :			List[Any]				=   image.shape[1], image.shape[2]
        a     :			Optional[int]				=   size / min(A				,		A			)
        if h < w:
          a,     a     :			Union[str, Any]				=   size, scale * w
        else:
          a,     a     :			int				=   scale * h, size

        a     :			Optional[int]				=   int((1_3_3_3 / 8_0_0) * size			)
        if max(A				,		A			) > max_size:
          a     :			Dict				=   max_size / max(A				,		A			)
          a     :			List[Any]				=   newh * scale
          a     :			List[Any]				=   neww * scale

        a,     a     :			Optional[int]				=   int(newh + 0.5			), int(neww + 0.5			)
        a,     a     :			Optional[Any]				=   (
            newh // self.size_divisor * self.size_divisor,
            neww // self.size_divisor * self.size_divisor,
        )

      else:
        a     :			Optional[Any]				=   []
        for image in image_inputs:
          a,     a     :			List[str]				=   self.get_expected_values([image]			)
          expected_values.append((expected_height, expected_width)			)
        a     :			Union[str, Any]				=   max(A				,		key=lambda A			: item[0]			)[0]
        a     :			List[str]				=   max(A				,		key=lambda A			: item[1]			)[1]

      return expected_height, expected_width






@require_torch
@require_vision
class 						snake_case  (  UpperCAmelCase   , unittest.TestCase       ):
    __magic_name__         =     ViltImageProcessor if is_vision_available() else None





    def 				lowerCamelCase__      (							self	:					Union[str, Any]			):


      '''simple docstring'''




      a     :			Union[str, Any]				=   ViltImageProcessingTester(self			)





    @property
    def 				lowerCamelCase__      (							self	:					Any			):


      '''simple docstring'''




      return self.image_processor_tester.prepare_image_processor_dict()





    def 				lowerCamelCase__      (							self	:					Optional[Any]			):


      '''simple docstring'''




      a     :			Union[str, Any]				=   self.image_processing_class(**self.image_processor_dict			)
      self.assertTrue(hasattr(A				,		'image_mean'			)			)
      self.assertTrue(hasattr(A				,		'image_std'			)			)
      self.assertTrue(hasattr(A				,		'do_normalize'			)			)
      self.assertTrue(hasattr(A				,		'do_resize'			)			)
      self.assertTrue(hasattr(A				,		'size'			)			)
      self.assertTrue(hasattr(A				,		'size_divisor'			)			)





    def 				lowerCamelCase__      (							self	:					Union[str, Any]			):


      '''simple docstring'''




      a     :			Dict				=   self.image_processing_class.from_dict(self.image_processor_dict			)
      self.assertEqual(image_processor.size				,		{'shortest_edge': 3_0}			)

      a     :			Union[str, Any]				=   self.image_processing_class.from_dict(self.image_processor_dict				,		size=4_2			)
      self.assertEqual(image_processor.size				,		{'shortest_edge': 4_2}			)





    def 				lowerCamelCase__      (							self	:					Union[str, Any]			):


      '''simple docstring'''




      pass





    def 				lowerCamelCase__      (							self	:					Optional[int]			):


      '''simple docstring'''




      a     :			Optional[int]				=   self.image_processing_class(**self.image_processor_dict			)
      # create random PIL images
      a     :			Dict				=   prepare_image_inputs(self.image_processor_tester				,		equal_resolution=A			)
      for image in image_inputs:
        self.assertIsInstance(A				,		Image.Image			)

      # Test not batched input
      a     :			int				=   image_processing(image_inputs[0]				,		return_tensors='pt'			).pixel_values

      a,     a     :			int				=   self.image_processor_tester.get_expected_values(A			)
      self.assertEqual(
          encoded_images.shape				,		(1, self.image_processor_tester.num_channels, expected_height, expected_width)				,		)

      # Test batched
      a     :			List[Any]				=   image_processing(A				,		return_tensors='pt'			).pixel_values

      a,     a     :			Optional[int]				=   self.image_processor_tester.get_expected_values(A				,		batched=A			)
      self.assertEqual(
          encoded_images.shape				,		(
              self.image_processor_tester.batch_size,
              self.image_processor_tester.num_channels,
              expected_height,
              expected_width,
          )				,		)





    def 				lowerCamelCase__      (							self	:					str			):


      '''simple docstring'''




      a     :			Any				=   self.image_processing_class(**self.image_processor_dict			)
      # create random numpy tensors
      a     :			List[str]				=   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
      a     :			str				=   image_processing(image_inputs[0]				,		return_tensors='pt'			).pixel_values

      a,     a     :			str				=   self.image_processor_tester.get_expected_values(A			)
      self.assertEqual(
          encoded_images.shape				,		(1, self.image_processor_tester.num_channels, expected_height, expected_width)				,		)

      # Test batched
      a     :			List[str]				=   image_processing(A				,		return_tensors='pt'			).pixel_values

      a,     a     :			Optional[int]				=   self.image_processor_tester.get_expected_values(A				,		batched=A			)
      self.assertEqual(
          encoded_images.shape				,		(
              self.image_processor_tester.batch_size,
              self.image_processor_tester.num_channels,
              expected_height,
              expected_width,
          )				,		)





    def 				lowerCamelCase__      (							self	:					Any			):


      '''simple docstring'''




      a     :			int				=   self.image_processing_class(**self.image_processor_dict			)
      # create random PyTorch tensors
      a     :			List[Any]				=   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
      a     :			int				=   image_processing(image_inputs[0]				,		return_tensors='pt'			).pixel_values

      a,     a     :			Optional[int]				=   self.image_processor_tester.get_expected_values(A			)
      self.assertEqual(
          encoded_images.shape				,		(1, self.image_processor_tester.num_channels, expected_height, expected_width)				,		)

      # Test batched
      a     :			Union[str, Any]				=   image_processing(A				,		return_tensors='pt'			).pixel_values

      a,     a     :			List[Any]				=   self.image_processor_tester.get_expected_values(A				,		batched=A			)
      self.assertEqual(
          encoded_images.shape				,		(
              self.image_processor_tester.batch_size,
              self.image_processor_tester.num_channels,
              expected_height,
              expected_width,
          )				,		)







'''simple docstring'''
import math
from itertools import permutations


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


def       a__    (  _SCREAMING_SNAKE_CASE					:    int     ,							_SCREAMING_SNAKE_CASE					:    list							)			-> bool:


	"""simple docstring"""





	UpperCAmelCase_ , UpperCAmelCase_			:	Any      =   0, len(_SCREAMING_SNAKE_CASE							) - 1
	while left <= right:
		UpperCAmelCase_			:	List[str]      =   (left + right) // 2
		if prime_list[middle] == target:
			return True
		elif prime_list[middle] < target:
			UpperCAmelCase_			:	Dict      =   middle + 1
		else:
			UpperCAmelCase_			:	int      =   middle - 1

	return False


def       a__    (  )			-> Tuple:


	"""simple docstring"""





	UpperCAmelCase_			:	Dict      =   [n for n in range(10_01     ,							1_00_00     ,							2							) if is_prime(_SCREAMING_SNAKE_CASE							)]
	UpperCAmelCase_			:	Optional[int]      =   []

	for number in prime_list:
		UpperCAmelCase_			:	Optional[Any]      =   []

		for prime_member in permutations(list(str(_SCREAMING_SNAKE_CASE							)							)							):
			UpperCAmelCase_			:	List[Any]      =   int("".join(_SCREAMING_SNAKE_CASE							)							)

			if prime % 2 == 0:
				continue

			if search(_SCREAMING_SNAKE_CASE     ,							_SCREAMING_SNAKE_CASE							):
				tmp_numbers.append(_SCREAMING_SNAKE_CASE							)

		tmp_numbers.sort()
		if len(_SCREAMING_SNAKE_CASE							) >= 3:
			candidates.append(_SCREAMING_SNAKE_CASE							)

	UpperCAmelCase_			:	Tuple      =   []
	for candidate in candidates:
		UpperCAmelCase_			:	Union[str, Any]      =   len(_SCREAMING_SNAKE_CASE							)
		UpperCAmelCase_			:	Any      =   False

		for i in range(_SCREAMING_SNAKE_CASE							):
			for j in range(i + 1     ,							_SCREAMING_SNAKE_CASE							):
				for k in range(j + 1     ,							_SCREAMING_SNAKE_CASE							):
					if (
					    abs(candidate[i] - candidate[j]							)
					    == abs(candidate[j] - candidate[k]							)
					    and len({candidate[i], candidate[j], candidate[k]}							) == 3
					):
						passed.append(
						    sorted([candidate[i], candidate[j], candidate[k]]							)							)
						UpperCAmelCase_			:	Optional[Any]      =   True

					if found:
						break
				if found:
					break
			if found:
				break

	UpperCAmelCase_			:	Any      =   set()
	for seq in passed:
		answer.add("".join([str(_SCREAMING_SNAKE_CASE							) for i in seq]							)							)

	return max(int(_SCREAMING_SNAKE_CASE							) for x in answer							)


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




