




import sys

sys.set_int_max_str_digits(0)  # type: ignore

def       UpperCAmelCase_							(   __UpperCAmelCase		:			int							)      ->				bool:
      SCREAMING_SNAKE_CASE_					=    [0] * 11
      SCREAMING_SNAKE_CASE_					=    [0] * 11

      # mark last 9 numbers
      for _ in range(9							):
            SCREAMING_SNAKE_CASE_					=    1
            SCREAMING_SNAKE_CASE_					=    number // 10
      # flag
      SCREAMING_SNAKE_CASE_					=    True

      # check last 9 numbers for pandigitality

      for x in range(9							):
            if not check_last[x + 1]:
                  SCREAMING_SNAKE_CASE_					=    False
      if not f:
            return f

      # mark first 9 numbers
      SCREAMING_SNAKE_CASE_					=    int(str(__UpperCAmelCase							)[:9]							)

      for _ in range(9							):
            SCREAMING_SNAKE_CASE_					=    1
            SCREAMING_SNAKE_CASE_					=    number // 10

      # check first 9 numbers for pandigitality

      for x in range(9							):
            if not check_front[x + 1]:
                  SCREAMING_SNAKE_CASE_					=    False
      return f

def       UpperCAmelCase_							(   __UpperCAmelCase		:			int							)      ->				bool:
      SCREAMING_SNAKE_CASE_					=    [0] * 11

      # mark last 9 numbers
      for _ in range(9							):
            SCREAMING_SNAKE_CASE_					=    1
            SCREAMING_SNAKE_CASE_					=    number // 10
      # flag
      SCREAMING_SNAKE_CASE_					=    True

      # check last 9 numbers for pandigitality

      for x in range(9							):
            if not check_last[x + 1]:
                  SCREAMING_SNAKE_CASE_					=    False
      return f

def       UpperCAmelCase_							(   )      ->				int:
      SCREAMING_SNAKE_CASE_					=    1
      SCREAMING_SNAKE_CASE_					=    1
      SCREAMING_SNAKE_CASE_					=    2
      # temporary Fibonacci numbers

      SCREAMING_SNAKE_CASE_					=    1
      SCREAMING_SNAKE_CASE_					=    1
      SCREAMING_SNAKE_CASE_					=    2
      # temporary Fibonacci numbers mod 1e9

      # mod m=1e9, done for fast optimisation
      SCREAMING_SNAKE_CASE_					=    [0] * 1_00_00_00
      SCREAMING_SNAKE_CASE_					=    10_00_00_00_00

      for x in range(1_00_00_00							):
            SCREAMING_SNAKE_CASE_					=    (aa + ba) % m
            SCREAMING_SNAKE_CASE_					=    ba % m
            SCREAMING_SNAKE_CASE_					=    ca % m
            if checka(__UpperCAmelCase							):
                  SCREAMING_SNAKE_CASE_					=    1

      for x in range(1_00_00_00							):
            SCREAMING_SNAKE_CASE_					=    a + b
            SCREAMING_SNAKE_CASE_					=    b
            SCREAMING_SNAKE_CASE_					=    c
            # perform check only if in tocheck
            if tocheck[x + 3] and check(__UpperCAmelCase							):
                  return x + 3  # first 2 already done
      return -1


if __name__ == "__main__":
   print(f'''{solution() = }''')








import gc
import tempfile
import unittest

import numpy as np
import torch

from diffusers import VersatileDiffusionDualGuidedPipeline
from diffusers.utils.testing_utils import load_image, nightly, require_torch_gpu, torch_device


lowerCamelCase__				:     int			       =							False





@nightly
@require_torch_gpu
class  lowerCamelCase_							(   unittest.TestCase      ):


 '''simple docstring'''







 def    lowerCAmelCase_						(							self						:	Optional[Any]		):
       # clean up the VRAM after each test
       super().tearDown()
       gc.collect()
       torch.cuda.empty_cache()



 def    lowerCAmelCase_						(							self						:	Optional[int]		):
       SCREAMING_SNAKE_CASE_					=    VersatileDiffusionDualGuidedPipeline.from_pretrained('shi-labs/versatile-diffusion'		)
       # remove text_unet
       pipe.remove_unused_weights()
       pipe.to(_lowerCAmelCase		)
       pipe.set_progress_bar_config(disable=_lowerCAmelCase		)

       SCREAMING_SNAKE_CASE_					=    load_image(
           'https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/versatile_diffusion/benz.jpg'		)

       SCREAMING_SNAKE_CASE_					=    torch.manual_seed(0		)
       SCREAMING_SNAKE_CASE_					=    pipe(
           prompt='first prompt'       ,       image=_lowerCAmelCase       ,       text_to_image_strength=0.75       ,       generator=_lowerCAmelCase       ,       guidance_scale=7.5       ,       num_inference_steps=2       ,       output_type='numpy'       ,       ).images

       with tempfile.TemporaryDirectory() as tmpdirname:
             pipe.save_pretrained(_lowerCAmelCase		)
             SCREAMING_SNAKE_CASE_					=    VersatileDiffusionDualGuidedPipeline.from_pretrained(_lowerCAmelCase		)

       pipe.to(_lowerCAmelCase		)
       pipe.set_progress_bar_config(disable=_lowerCAmelCase		)

       SCREAMING_SNAKE_CASE_					=    generator.manual_seed(0		)
       SCREAMING_SNAKE_CASE_					=    pipe(
           prompt='first prompt'       ,       image=_lowerCAmelCase       ,       text_to_image_strength=0.75       ,       generator=_lowerCAmelCase       ,       guidance_scale=7.5       ,       num_inference_steps=2       ,       output_type='numpy'       ,       ).images

       assert np.abs(image - new_image		).sum() < 1E-5, "Models don't have the same forward pass"




 def    lowerCAmelCase_						(							self						:	Any		):
       SCREAMING_SNAKE_CASE_					=    VersatileDiffusionDualGuidedPipeline.from_pretrained('shi-labs/versatile-diffusion'		)
       pipe.remove_unused_weights()
       pipe.to(_lowerCAmelCase		)
       pipe.set_progress_bar_config(disable=_lowerCAmelCase		)

       SCREAMING_SNAKE_CASE_					=    'cyberpunk 2077'
       SCREAMING_SNAKE_CASE_					=    load_image(
           'https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/versatile_diffusion/benz.jpg'		)
       SCREAMING_SNAKE_CASE_					=    torch.manual_seed(0		)
       SCREAMING_SNAKE_CASE_					=    pipe(
           prompt=_lowerCAmelCase       ,       image=_lowerCAmelCase       ,       text_to_image_strength=0.75       ,       generator=_lowerCAmelCase       ,       guidance_scale=7.5       ,       num_inference_steps=50       ,       output_type='numpy'       ,       ).images

       SCREAMING_SNAKE_CASE_					=    image[0, 253:256, 253:256, -1]

       assert image.shape == (1, 512, 512, 3)
       SCREAMING_SNAKE_CASE_					=    np.array([0.0787, 0.0849, 0.0826, 0.0812, 0.0807, 0.0795, 0.0818, 0.0798, 0.0779]		)

       assert np.abs(image_slice.flatten() - expected_slice		).max() < 1E-2