





'''simple docstring'''







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 					__a      (unittest.TestCase     ):

							@property
							def     UpperCAmelCase__	(							self							:     Optional[int]   )					->       List[str]:







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

							@property
							def     UpperCAmelCase__	(							self							:     Optional[int]   )					->       Dict:







													"""simple docstring"""
													UpperCAmelCase_			:      Any     						=  ort.SessionOptions()
													UpperCAmelCase_			:      Optional[Any]     						=  False
													return options



							def     UpperCAmelCase__	(							self							:     int   )					->       Optional[int]:







													"""simple docstring"""
													UpperCAmelCase_			:      List[Any]     						=  load_image(
													    '''https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main'''
													    '''/in_paint/overture-creations-5sI6fQgYIuo.png'''   )
													UpperCAmelCase_			:      Tuple     						=  load_image(
													    '''https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main'''
													    '''/in_paint/overture-creations-5sI6fQgYIuo_mask.png'''   )
													UpperCAmelCase_			:      List[Any]     						=  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_			:      str     						=  OnnxStableDiffusionInpaintPipelineLegacy.from_pretrained(
													    '''CompVis/stable-diffusion-v1-4'''       ,     revision='''onnx'''       ,     safety_checker=__magic_name__       ,     feature_extractor=__magic_name__       ,     provider=self.gpu_provider       ,     sess_options=self.gpu_options       ,     )
													pipe.set_progress_bar_config(disable=__magic_name__   )

													UpperCAmelCase_			:      List[Any]     						=  '''A red cat sitting on a park bench'''

													UpperCAmelCase_			:      str     						=  np.random.RandomState(0   )
													UpperCAmelCase_			:      int     						=  pipe(
													    prompt=__magic_name__       ,     image=__magic_name__       ,     mask_image=__magic_name__       ,     strength=0.7_5       ,     guidance_scale=7.5       ,     num_inference_steps=15       ,     generator=__magic_name__       ,     output_type='''np'''       ,     )

													UpperCAmelCase_			:      Union[str, Any]     						=  output.images[0]

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












'''simple docstring'''







def        lowerCamelCase_      (  SCREAMING_SNAKE_CASE__      :			list[int]   ) ->	list[list[int]]:
						UpperCAmelCase_			:      int     						=  []
						if len(SCREAMING_SNAKE_CASE__   ) == 1:
												return [nums.copy()]
						for _ in range(len(SCREAMING_SNAKE_CASE__   )   ):
												UpperCAmelCase_			:      List[Any]     						=  nums.pop(0   )
												UpperCAmelCase_			:      Optional[Any]     						=  permute(SCREAMING_SNAKE_CASE__   )
												for perm in permutations:
																		perm.append(SCREAMING_SNAKE_CASE__   )
												result.extend(SCREAMING_SNAKE_CASE__   )
												nums.append(SCREAMING_SNAKE_CASE__   )
						return result





def        lowerCamelCase_      (  SCREAMING_SNAKE_CASE__      :			List[str]   ) ->	Any:

						def backtrack(SCREAMING_SNAKE_CASE__      :			Union[str, Any]   ):
												if start == len(SCREAMING_SNAKE_CASE__   ) - 1:
																		output.append(nums[:]   )
												else:
																		for i in range(SCREAMING_SNAKE_CASE__,			len(SCREAMING_SNAKE_CASE__   )   ):
																								UpperCAmelCase_						,       UpperCAmelCase_			:      Tuple     						=  nums[i], nums[start]
																								backtrack(start + 1   )
																								UpperCAmelCase_						,       UpperCAmelCase_			:      int     						=  nums[i], nums[start]  # backtrack

						UpperCAmelCase_			:      Optional[int]     						=  []
						backtrack(0   )
						return output


if __name__ == "__main__":
					import doctest

					# use res to print the data in permute2 function
					snake_case_     :       Tuple						=  permutea([1, 2, 3])
					print(res)
					doctest.testmod()





