





import math

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

def      UpperCAmelCase_    (    _UpperCAmelCase							:float = 0.1				)	->				int:
     '''simple docstring'''


     A_          =       3
     A_          =       3

     while primes / (2 * j - 1) >= ratio:
          for i in range(j * j + j + 1  ,						(j + 2) * (j + 2)  ,						j + 1				):
               primes += is_prime(_UpperCAmelCase				)
          j += 2
     return j


if __name__ == "__main__":
      import doctest

      doctest.testmod()










import unittest

import numpy as np
import torch

from diffusers import VersatileDiffusionImageVariationPipeline
from diffusers.utils.testing_utils import load_image, require_torch_gpu, slow, torch_device


a__      :     Optional[int]         =		False





class UpperCAmelCase_				( unittest.TestCase ):
  pass





@slow
@require_torch_gpu
class UpperCAmelCase_				( unittest.TestCase ):


  def 						__UpperCAmelCase     (							self ):



       """simple docstring"""





       A_          =       VersatileDiffusionImageVariationPipeline.from_pretrained('''shi-labs/versatile-diffusion''' )
       pipe.to(__snake_case )
       pipe.set_progress_bar_config(disable=__snake_case )

       A_          =       load_image(
           '''https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/versatile_diffusion/benz.jpg''' )
       A_          =       torch.manual_seed(0 )
       A_          =       pipe(
           image=__snake_case ,generator=__snake_case ,guidance_scale=7.5 ,num_inference_steps=5_0 ,output_type='''numpy''' ,).images

       A_          =       image[0, 2_5_3:2_5_6, 2_5_3:2_5_6, -1]

       assert image.shape == (1, 5_1_2, 5_1_2, 3)
       A_          =       np.array([0.0441, 0.0469, 0.0507, 0.0575, 0.0632, 0.0650, 0.0865, 0.0909, 0.0945] )

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



