


'''simple docstring'''





def __UpperCAmelCase       (		__A			)						->					list:



       '''simple docstring'''





       if any(not isinstance(__snake_case ,						__snake_case			) or x < 0 for x in sequence			):
              raise TypeError("Sequence must be list of non-negative integers"			)
       for _ in range(len(__snake_case			)			):
              for i, (rod_upper, rod_lower) in enumerate(zip(__snake_case ,						sequence[1:]			)			):
                     if rod_upper > rod_lower:
                            sequence[i] -= rod_upper - rod_lower
                            sequence[i + 1] += rod_upper - rod_lower
       return sequence


if __name__ == "__main__":
    assert bead_sort([5, 4, 3, 2, 1]) == [1, 2, 3, 4, 5]
    assert bead_sort([7, 9, 4, 3, 5]) == [3, 4, 5, 7, 9]









import unittest

import numpy as np

from diffusers import OnnxStableDiffusionInpaintPipelineLegacy
from diffusers.utils.testing_utils import (
    is_onnx_available,
    load_image,
    load_numpy,
    nightly,
    require_onnxruntime,
    require_torch_gpu,
)


if is_onnx_available():
    import onnxruntime as ort


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






  @property
  def 			_UpperCAmelCase  (					self      :					Union[str, Any] ):




         """simple docstring"""







         return (
             "CUDAExecutionProvider",
             {
                 "gpu_mem_limit": "15000000000",  # 15GB
                 "arena_extend_strategy": "kSameAsRequested",
             },
         )






  @property
  def 			_UpperCAmelCase  (					self      :					Optional[Any] ):




         """simple docstring"""







         UpperCAmelCase__										=     ort.SessionOptions()
         UpperCAmelCase__										=     False
         return options






  def 			_UpperCAmelCase  (					self      :					Dict ):




         """simple docstring"""







         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__										=     load_numpy(
             "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main"
             "/in_paint/red_cat_sitting_on_a_park_bench_onnx.npy" )

         # using the PNDM scheduler by default
         UpperCAmelCase__										=     OnnxStableDiffusionInpaintPipelineLegacy.from_pretrained(
             "CompVis/stable-diffusion-v1-4"		,						revision="onnx"		,						safety_checker=_lowercase		,						feature_extractor=_lowercase		,						provider=self.gpu_provider		,						sess_options=self.gpu_options		,						)
         pipe.set_progress_bar_config(disable=_lowercase )

         UpperCAmelCase__										=     "A red cat sitting on a park bench"

         UpperCAmelCase__										=     np.random.RandomState(0 )
         UpperCAmelCase__										=     pipe(
             prompt=_lowercase		,						image=_lowercase		,						mask_image=_lowercase		,						strength=0.7_5		,						guidance_scale=7.5		,						num_inference_steps=15		,						generator=_lowercase		,						output_type="np"		,						)

         UpperCAmelCase__										=     output.images[0]

         assert image.shape == (5_12, 5_12, 3)
         assert np.abs(expected_image - image ).max() < 1E-2





