


'''simple docstring'''



import random
import unittest

import torch

from diffusers import IFSuperResolutionPipeline
from diffusers.utils import floats_tensor
from diffusers.utils.import_utils import is_xformers_available
from diffusers.utils.testing_utils import skip_mps, torch_device

from ..pipeline_params import TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS, TEXT_GUIDED_IMAGE_VARIATION_PARAMS
from ..test_pipelines_common import PipelineTesterMixin
from . import IFPipelineTesterMixin





@skip_mps
class        UpperCAmelCase_  (_UpperCAmelCase ,		_UpperCAmelCase ,		unittest.TestCase  ):





    """simple docstring"""






    lowerCamelCase  : str												=      IFSuperResolutionPipeline
    lowerCamelCase  : Any												=      TEXT_GUIDED_IMAGE_VARIATION_PARAMS - {'width', 'height'}
    lowerCamelCase  : str												=      TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS
    lowerCamelCase  : List[str]												=      PipelineTesterMixin.required_optional_params - {'latents'}







    def 				lowercase_    (							self     )    ->					str:
         return self._get_superresolution_dummy_components()







    def 				lowercase_    (							self      ,					SCREAMING_SNAKE_CASE_      ,					SCREAMING_SNAKE_CASE_=0     )    ->					Any:
         if str(SCREAMING_SNAKE_CASE_     ).startswith('mps'     ):
              __lowerCamelCase       :     Optional[Any]        =		torch.manual_seed(SCREAMING_SNAKE_CASE_     )
         else:
              __lowerCamelCase       :     Dict        =		torch.Generator(device=SCREAMING_SNAKE_CASE_     ).manual_seed(SCREAMING_SNAKE_CASE_     )

         __lowerCamelCase       :     str        =		floats_tensor((1, 3, 32, 32)      ,					rng=random.Random(SCREAMING_SNAKE_CASE_     )     ).to(SCREAMING_SNAKE_CASE_     )

         __lowerCamelCase       :     int        =		{
             'prompt': 'A painting of a squirrel eating a burger',
             'image': image,
             'generator': generator,
             'num_inference_steps': 2,
             'output_type': 'numpy',
         }

         return inputs







    @unittest.skipIf(
        torch_device != 'cuda' or not is_xformers_available()      ,					reason='XFormers attention is only available with CUDA and `xformers` installed'      ,					)
    def 				lowercase_    (							self     )    ->					int:
         self._test_xformers_attention_forwardGenerator_pass(expected_max_diff=1E-3     )







    def 				lowercase_    (							self     )    ->					Tuple:
         self._test_save_load_optional_components()







    @unittest.skipIf(torch_device != 'cuda'      ,					reason='float16 requires CUDA'     )
    def 				lowercase_    (							self     )    ->					List[str]:
         # Due to non-determinism in save load of the hf-internal-testing/tiny-random-t5 text encoder
         super().test_save_load_floataa(expected_max_diff=1E-1     )







    def 				lowercase_    (							self     )    ->					Dict:
         self._test_attention_slicing_forward_pass(expected_max_diff=1E-2     )







    def 				lowercase_    (							self     )    ->					Any:
         self._test_save_load_local()







    def 				lowercase_    (							self     )    ->					List[str]:
         self._test_inference_batch_single_identical(
             expected_max_diff=1E-2      ,					)










'''simple docstring'''



import math
from itertools import permutations



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



def       UpperCAmelCase__ (     UpperCAmelCase_   :    int				,   UpperCAmelCase_   :    list							)					->		bool:
     __lowerCamelCase    ,	__lowerCamelCase       :     str        =		0, len(UpperCAmelCase_							) - 1
     while left <= right:
          __lowerCamelCase       :     Optional[Any]        =		(left + right) // 2
          if prime_list[middle] == target:
               return True
          elif prime_list[middle] < target:
               __lowerCamelCase       :     Union[str, Any]        =		middle + 1
          else:
               __lowerCamelCase       :     Union[str, Any]        =		middle - 1

     return False



def       UpperCAmelCase__ (     )					->		List[str]:
     __lowerCamelCase       :     Tuple        =		[n for n in range(10_01				,   1_00_00				,   2							) if is_prime(UpperCAmelCase_							)]
     __lowerCamelCase       :     Any        =		[]

     for number in prime_list:
          __lowerCamelCase       :     Optional[int]        =		[]

          for prime_member in permutations(list(str(UpperCAmelCase_							)							)							):
               __lowerCamelCase       :     int        =		int(''.join(UpperCAmelCase_							)							)

               if prime % 2 == 0:
                    continue

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

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

     __lowerCamelCase       :     int        =		[]
     for candidate in candidates:
          __lowerCamelCase       :     Union[str, Any]        =		len(UpperCAmelCase_							)
          __lowerCamelCase       :     Optional[Any]        =		False

          for i in range(UpperCAmelCase_							):
               for j in range(i + 1				,   UpperCAmelCase_							):
                    for k in range(j + 1				,   UpperCAmelCase_							):
                         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]]							)							)
                              __lowerCamelCase       :     List[str]        =		True

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

     __lowerCamelCase       :     List[Any]        =		set()
     for seq in passed:
          answer.add(''.join([str(UpperCAmelCase_							) for i in seq]							)							)

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


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






