

import json
import os
import tempfile

from transformers.testing_utils import check_json_file_has_correct_format, require_torch, require_vision
from transformers.utils import is_torch_available, is_vision_available


if is_torch_available():
						import numpy as np
						import torch

if is_vision_available():
						from PIL import Image





def    _snake_case		(snake_case_				:    Optional[Any]						,					snake_case_				:    Tuple=False						,					snake_case_				:    Dict=False						,					snake_case_				:    Optional[Any]=False     )       ->		List[str]:
		assert not (numpify and torchify), "You cannot specify both numpy and PyTorch tensors at the same time"

		__UpperCAmelCase  :     int		=    []
		for i in range(image_processor_tester.batch_size     ):
				if equal_resolution:
						__UpperCAmelCase  :     Optional[int]		=    image_processor_tester.max_resolution
				else:
						# To avoid getting image width/height 0
						__UpperCAmelCase  :     Optional[Any]		=    image_processor_tester.min_resolution
						if getattr(snake_case_						,					'size_divisor'						,					snake_case_     ):
								# If `size_divisor` is defined, the image needs to have width/size >= `size_divisor`
								__UpperCAmelCase  :     List[str]		=    max(image_processor_tester.size_divisor						,					snake_case_     )
						__UpperCAmelCase  :     List[str]		=    np.random.choice(np.arange(snake_case_						,					image_processor_tester.max_resolution     )						,					2     )
				image_inputs.append(
				    np.random.randint(255						,					size=(image_processor_tester.num_channels, width, height)						,					dtype=np.uinta     )     )

		if not numpify and not torchify:
				# PIL expects the channel dimension as last dimension
				__UpperCAmelCase  :     Tuple		=    [Image.fromarray(np.moveaxis(snake_case_						,					0						,					-1     )     ) for image in image_inputs]

		if torchify:
				__UpperCAmelCase  :     Any		=    [torch.from_numpy(snake_case_     ) for image in image_inputs]

		return image_inputs





def    _snake_case		(snake_case_				:    Any						,					snake_case_				:    Tuple=10						,					snake_case_				:    List[Any]=10						,					snake_case_				:    List[Any]=False						,					snake_case_				:    Any=False     )       ->		Any:
		__UpperCAmelCase  :     Optional[int]		=    []
		for i in range(image_processor_tester.num_frames     ):
				video.append(np.random.randint(255						,					size=(image_processor_tester.num_channels, width, height)						,					dtype=np.uinta     )     )

		if not numpify and not torchify:
				# PIL expects the channel dimension as last dimension
				__UpperCAmelCase  :     str		=    [Image.fromarray(np.moveaxis(snake_case_						,					0						,					-1     )     ) for frame in video]

		if torchify:
				__UpperCAmelCase  :     Optional[Any]		=    [torch.from_numpy(snake_case_     ) for frame in video]

		return video





def    _snake_case		(snake_case_				:    Optional[int]						,					snake_case_				:    str=False						,					snake_case_				:    str=False						,					snake_case_				:    Optional[int]=False     )       ->		Union[str, Any]:
		assert not (numpify and torchify), "You cannot specify both numpy and PyTorch tensors at the same time"

		__UpperCAmelCase  :     Optional[Any]		=    []
		for i in range(image_processor_tester.batch_size     ):
				if equal_resolution:
						__UpperCAmelCase  :     List[Any]		=    image_processor_tester.max_resolution
				else:
						__UpperCAmelCase  :     Any		=    np.random.choice(
						    np.arange(image_processor_tester.min_resolution						,					image_processor_tester.max_resolution     )						,					2     )
						__UpperCAmelCase  :     str		=    prepare_video(
						    image_processor_tester=snake_case_						,					width=snake_case_						,					height=snake_case_						,					numpify=snake_case_						,					torchify=snake_case_						,					)
				video_inputs.append(snake_case_     )

		return video_inputs







class     lowerCamelCase_   :
	_lowerCAmelCase       		=  None




	def 						a					( self       ):
			__UpperCAmelCase  :     Dict		=    self.image_processing_class(**self.image_processor_dict       )
			__UpperCAmelCase  :     Tuple		=    json.loads(image_processor.to_json_string()       )
			for key, value in self.image_processor_dict.items():
					self.assertEqual(obj[key]     ,     _UpperCAmelCase       )




	def 						a					( self       ):
			__UpperCAmelCase  :     Optional[int]		=    self.image_processing_class(**self.image_processor_dict       )

			with tempfile.TemporaryDirectory() as tmpdirname:
					__UpperCAmelCase  :     Optional[int]		=    os.path.join(_UpperCAmelCase     ,     'image_processor.json'       )
					image_processor_first.to_json_file(_UpperCAmelCase       )
					__UpperCAmelCase  :     Any		=    self.image_processing_class.from_json_file(_UpperCAmelCase       )

			self.assertEqual(image_processor_second.to_dict()     ,     image_processor_first.to_dict()       )




	def 						a					( self       ):
			__UpperCAmelCase  :     Optional[Any]		=    self.image_processing_class(**self.image_processor_dict       )

			with tempfile.TemporaryDirectory() as tmpdirname:
					__UpperCAmelCase  :     Dict		=    image_processor_first.save_pretrained(_UpperCAmelCase       )[0]
					check_json_file_has_correct_format(_UpperCAmelCase       )
					__UpperCAmelCase  :     Union[str, Any]		=    self.image_processing_class.from_pretrained(_UpperCAmelCase       )

			self.assertEqual(image_processor_second.to_dict()     ,     image_processor_first.to_dict()       )




	def 						a					( self       ):
			__UpperCAmelCase  :     str		=    self.image_processing_class()
			self.assertIsNotNone(_UpperCAmelCase       )




	@require_torch
	@require_vision
	def 						a					( self       ):
			if self.test_cast_dtype is not None:
					# Initialize image_processor
					__UpperCAmelCase  :     Any		=    self.image_processing_class(**self.image_processor_dict       )

					# create random PyTorch tensors
					__UpperCAmelCase  :     Optional[int]		=    prepare_image_inputs(self.image_processor_tester     ,     equal_resolution=_UpperCAmelCase     ,     torchify=_UpperCAmelCase       )

					__UpperCAmelCase  :     List[Any]		=    image_processor(_UpperCAmelCase     ,     return_tensors='pt'       )
					# for layoutLM compatiblity
					self.assertEqual(encoding.pixel_values.device     ,     torch.device('cpu'       )       )
					self.assertEqual(encoding.pixel_values.dtype     ,     torch.floataa       )

					__UpperCAmelCase  :     Dict		=    image_processor(_UpperCAmelCase     ,     return_tensors='pt'       ).to(torch.floataa       )
					self.assertEqual(encoding.pixel_values.device     ,     torch.device('cpu'       )       )
					self.assertEqual(encoding.pixel_values.dtype     ,     torch.floataa       )

					__UpperCAmelCase  :     Tuple		=    image_processor(_UpperCAmelCase     ,     return_tensors='pt'       ).to('cpu'     ,     torch.bfloataa       )
					self.assertEqual(encoding.pixel_values.device     ,     torch.device('cpu'       )       )
					self.assertEqual(encoding.pixel_values.dtype     ,     torch.bfloataa       )

					with self.assertRaises(_UpperCAmelCase       ):
							__UpperCAmelCase  :     Tuple		=    image_processor(_UpperCAmelCase     ,     return_tensors='pt'       ).to(torch.bfloataa     ,     'cpu'       )

					# Try with text + image feature
					__UpperCAmelCase  :     Any		=    image_processor(_UpperCAmelCase     ,     return_tensors='pt'       )
					encoding.update({'input_ids': torch.LongTensor([[1, 2, 3], [4, 5, 6]]       )}       )
					__UpperCAmelCase  :     List[Any]		=    encoding.to(torch.floataa       )

					self.assertEqual(encoding.pixel_values.device     ,     torch.device('cpu'       )       )
					self.assertEqual(encoding.pixel_values.dtype     ,     torch.floataa       )
					self.assertEqual(encoding.input_ids.dtype     ,     torch.long       )








import math
from itertools import permutations





def    _snake_case		(snake_case_				:    int     )       ->		bool:

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





def    _snake_case		(snake_case_				:    int						,					snake_case_				:    list     )       ->		bool:
  __UpperCAmelCase, __UpperCAmelCase  :     Any		=    0, len(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  :     Tuple		=    middle + 1
    else:
      __UpperCAmelCase  :     Tuple		=    middle - 1

  return False





def    _snake_case		()       ->		str:
  __UpperCAmelCase  :     List[Any]		=    [n for n in range(1001						,					1_0000						,					2     ) if is_prime(snake_case_     )]
  __UpperCAmelCase  :     Tuple		=    []

  for number in prime_list:
    __UpperCAmelCase  :     List[str]		=    []

    for prime_member in permutations(list(str(snake_case_     )     )     ):
      __UpperCAmelCase  :     Dict		=    int(''.join(snake_case_     )     )

      if prime % 2 == 0:
        continue

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

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

  __UpperCAmelCase  :     Optional[int]		=    []
  for candidate in candidates:
    __UpperCAmelCase  :     int		=    len(snake_case_     )
    __UpperCAmelCase  :     List[Any]		=    False

    for i in range(snake_case_     ):
      for j in range(i + 1						,					snake_case_     ):
        for k in range(j + 1						,					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  :     Any		=    True

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

  __UpperCAmelCase  :     Dict		=    set()
  for seq in passed:
    answer.add(''.join([str(snake_case_     ) for i in seq]     )     )

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


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





