





'''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 			_lowercase						(       __a				,		unittest.TestCase					):
     # FIXME: add fast tests
     pass




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







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







     @property
     def     UpperCamelCase			( self    ) ->	Optional[int]:
      snake_case				=			ort.SessionOptions()
      snake_case				=			False
      return options







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

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

      snake_case				=			np.random.RandomState(0    )
      snake_case				=			pipe(
          prompt=A__    ,   image=A__    ,   mask_image=A__    ,   guidance_scale=7.5    ,   num_inference_steps=10    ,   generator=A__    ,   output_type='''np'''    ,   )
      snake_case				=			output.images
      snake_case				=			images[0, 2_55:2_58, 2_55:2_58, -1]

      assert images.shape == (1, 5_12, 5_12, 3)
      snake_case				=			np.array([0.2_5_1_4, 0.3_0_0_7, 0.3_5_1_7, 0.1_7_9_0, 0.2_3_8_2, 0.3_1_6_7, 0.1_9_4_4, 0.2_2_7_3, 0.2_4_6_4]    )

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







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

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

      snake_case				=			np.random.RandomState(0    )
      snake_case				=			pipe(
          prompt=A__    ,   image=A__    ,   mask_image=A__    ,   guidance_scale=7.5    ,   num_inference_steps=20    ,   generator=A__    ,   output_type='''np'''    ,   )
      snake_case				=			output.images
      snake_case				=			images[0, 2_55:2_58, 2_55:2_58, -1]

      assert images.shape == (1, 5_12, 5_12, 3)
      snake_case				=			np.array([0.0_0_8_6, 0.0_0_7_7, 0.0_0_8_3, 0.0_0_9_3, 0.0_1_0_7, 0.0_1_3_9, 0.0_0_9_4, 0.0_0_9_7, 0.0_1_2_5]    )

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








'''simple docstring'''







def    __UpperCamelCase	(	a    : int					,   a    : int     ) ->int:
 while b:
  snake_case				,		snake_case				=			b, a % b
 return a

def    __UpperCamelCase	(	a    : int					,   a    : int     ) ->int:
 return a if b == 0 else euclidean_gcd_recursive(a					,   a % b     )

def    __UpperCamelCase	(	) ->Optional[Any]:
 print(f"""euclidean_gcd(3, 5) = {euclidean_gcd(3					,   5     )}"""     )
 print(f"""euclidean_gcd(5, 3) = {euclidean_gcd(5					,   3     )}"""     )
 print(f"""euclidean_gcd(1, 3) = {euclidean_gcd(1					,   3     )}"""     )
 print(f"""euclidean_gcd(3, 6) = {euclidean_gcd(3					,   6     )}"""     )
 print(f"""euclidean_gcd(6, 3) = {euclidean_gcd(6					,   3     )}"""     )

 print(f"""euclidean_gcd_recursive(3, 5) = {euclidean_gcd_recursive(3					,   5     )}"""     )
 print(f"""euclidean_gcd_recursive(5, 3) = {euclidean_gcd_recursive(5					,   3     )}"""     )
 print(f"""euclidean_gcd_recursive(1, 3) = {euclidean_gcd_recursive(1					,   3     )}"""     )
 print(f"""euclidean_gcd_recursive(3, 6) = {euclidean_gcd_recursive(3					,   6     )}"""     )
 print(f"""euclidean_gcd_recursive(6, 3) = {euclidean_gcd_recursive(6					,   3     )}"""     )


if __name__ == "__main__":
   main()

