






"""simple docstring"""





import unittest

import numpy as np

from diffusers import LMSDiscreteScheduler, OnnxStableDiffusionInpaintPipeline
from diffusers.utils.testing_utils import (
    is_onnx_available,
    load_image,
    nightly,
    require_onnxruntime,
    require_torch_gpu,
)

from ..test_pipelines_onnx_common import OnnxPipelineTesterMixin


if is_onnx_available():
  import onnxruntime as ort
class    __lowerCamelCase    (  _a							,	unittest.TestCase  ):
   # FIXME: add fast tests
   pass







@nightly
@require_onnxruntime
@require_torch_gpu
class    __lowerCamelCase    (  unittest.TestCase  ):

   @property
   def 						SCREAMING_SNAKE_CASE__ (					self      )		->       Union[str, Any]:
       return (
           "CUDAExecutionProvider",
           {
               "gpu_mem_limit": "15000000000",  # 15GB
               "arena_extend_strategy": "kSameAsRequested",
           },
       )

   @property
   def 						SCREAMING_SNAKE_CASE__ (					self      )		->       Optional[Any]:
       UpperCamelCase__         =    ort.SessionOptions()
       UpperCamelCase__         =    False
       return options

   def 						SCREAMING_SNAKE_CASE__ (					self      )		->       int:
       UpperCamelCase__         =    load_image(
           'https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main'
           '/in_paint/overture-creations-5sI6fQgYIuo.png'      )
       UpperCamelCase__         =    load_image(
           'https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main'
           '/in_paint/overture-creations-5sI6fQgYIuo_mask.png'      )
       UpperCamelCase__         =    OnnxStableDiffusionInpaintPipeline.from_pretrained(
           'runwayml/stable-diffusion-inpainting' ,				revision='onnx' ,				safety_checker=snake_case_ ,				feature_extractor=snake_case_ ,				provider=self.gpu_provider ,				sess_options=self.gpu_options ,				)
       pipe.set_progress_bar_config(disable=snake_case_      )

       UpperCamelCase__         =    'A red cat sitting on a park bench'

       UpperCamelCase__         =    np.random.RandomState(0      )
       UpperCamelCase__         =    pipe(
           prompt=snake_case_ ,				image=snake_case_ ,				mask_image=snake_case_ ,				guidance_scale=7.5 ,				num_inference_steps=10 ,				generator=snake_case_ ,				output_type='np' ,				)
       UpperCamelCase__         =    output.images
       UpperCamelCase__         =    images[0, 255:258, 255:258, -1]

       assert images.shape == (1, 512, 512, 3)
       UpperCamelCase__         =    np.array([0.2_514, 0.3_007, 0.3_517, 0.1_790, 0.2_382, 0.3_167, 0.1_944, 0.2_273, 0.2_464]      )

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







   def 						SCREAMING_SNAKE_CASE__ (					self      )		->       List[str]:
       UpperCamelCase__         =    load_image(
           'https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main'
           '/in_paint/overture-creations-5sI6fQgYIuo.png'      )
       UpperCamelCase__         =    load_image(
           'https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main'
           '/in_paint/overture-creations-5sI6fQgYIuo_mask.png'      )
       UpperCamelCase__         =    LMSDiscreteScheduler.from_pretrained(
           'runwayml/stable-diffusion-inpainting' ,				subfolder='scheduler' ,				revision='onnx'      )
       UpperCamelCase__         =    OnnxStableDiffusionInpaintPipeline.from_pretrained(
           'runwayml/stable-diffusion-inpainting' ,				revision='onnx' ,				scheduler=snake_case_ ,				safety_checker=snake_case_ ,				feature_extractor=snake_case_ ,				provider=self.gpu_provider ,				sess_options=self.gpu_options ,				)
       pipe.set_progress_bar_config(disable=snake_case_      )

       UpperCamelCase__         =    'A red cat sitting on a park bench'

       UpperCamelCase__         =    np.random.RandomState(0      )
       UpperCamelCase__         =    pipe(
           prompt=snake_case_ ,				image=snake_case_ ,				mask_image=snake_case_ ,				guidance_scale=7.5 ,				num_inference_steps=20 ,				generator=snake_case_ ,				output_type='np' ,				)
       UpperCamelCase__         =    output.images
       UpperCamelCase__         =    images[0, 255:258, 255:258, -1]

       assert images.shape == (1, 512, 512, 3)
       UpperCamelCase__         =    np.array([0.0_086, 0.0_077, 0.0_083, 0.0_093, 0.0_107, 0.0_139, 0.0_094, 0.0_097, 0.0_125]      )

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












"""simple docstring"""





def   lowerCAmelCase_( SCREAMING_SNAKE_CASE = 50_00_00_00					)					->	int:
    """simple docstring"""

    UpperCamelCase__         =    set()
    UpperCamelCase__         =    int((limit - 24) ** (1 / 2)					)

    UpperCamelCase__         =    set(range(3 ,	prime_square_limit + 1 ,	2					)					)
    primes.add(2					)
    for p in range(3 ,	prime_square_limit + 1 ,	2					):
        if p not in primes:
            continue
        primes.difference_update(set(range(p * p ,	prime_square_limit + 1 ,	SCREAMING_SNAKE_CASE					)					)					)

    for primea in primes:
        UpperCamelCase__         =    primea * primea
        for primea in primes:
            UpperCamelCase__         =    primea * primea * primea
            if square + cube >= limit - 16:
                break
            for primea in primes:
                UpperCamelCase__         =    primea * primea * primea * primea
                UpperCamelCase__         =    square + cube + tetr
                if total >= limit:
                    break
                ret.add(SCREAMING_SNAKE_CASE					)

    return len(SCREAMING_SNAKE_CASE					)


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




