

'''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 						_snake_case							(			self)							->				List[Any]:
								return (
								    "CUDAExecutionProvider",
								    {
								        "gpu_mem_limit": "15000000000",  # 15GB
								        "arena_extend_strategy": "kSameAsRequested",
								    },
								)


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


							def 						_snake_case							(			self)							->				List[str]:
								UpperCAmelCase_		:      Optional[Any]       	=					load_image(
								    'https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main'
								    '/in_paint/overture-creations-5sI6fQgYIuo.png')
								UpperCAmelCase_		:      Any       	=					load_image(
								    'https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main'
								    '/in_paint/overture-creations-5sI6fQgYIuo_mask.png')
								UpperCAmelCase_		:      Union[str, Any]       	=					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__)

								UpperCAmelCase_		:      Dict       	=					'A red cat sitting on a park bench'

								UpperCAmelCase_		:      Any       	=					np.random.RandomState(0)
								UpperCAmelCase_		:      str       	=					pipe(
								    prompt=A__    ,			image=A__    ,			mask_image=A__    ,			guidance_scale=7.5    ,			num_inference_steps=10    ,			generator=A__    ,			output_type='np'    ,			)
								UpperCAmelCase_		:      List[str]       	=					output.images
								UpperCAmelCase_		:      int       	=					images[0, 255:258, 255:258, -1]

								assert images.shape == (1, 512, 512, 3)
								UpperCAmelCase_		:      List[Any]       	=					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 						_snake_case							(			self)							->				int:
								UpperCAmelCase_		:      Optional[Any]       	=					load_image(
								    'https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main'
								    '/in_paint/overture-creations-5sI6fQgYIuo.png')
								UpperCAmelCase_		:      List[str]       	=					load_image(
								    'https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main'
								    '/in_paint/overture-creations-5sI6fQgYIuo_mask.png')
								UpperCAmelCase_		:      List[Any]       	=					LMSDiscreteScheduler.from_pretrained(
								    'runwayml/stable-diffusion-inpainting'    ,			subfolder='scheduler'    ,			revision='onnx')
								UpperCAmelCase_		:      str       	=					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__)

								UpperCAmelCase_		:      Optional[int]       	=					'A red cat sitting on a park bench'

								UpperCAmelCase_		:      Optional[Any]       	=					np.random.RandomState(0)
								UpperCAmelCase_		:      List[str]       	=					pipe(
								    prompt=A__    ,			image=A__    ,			mask_image=A__    ,			guidance_scale=7.5    ,			num_inference_steps=20    ,			generator=A__    ,			output_type='np'    ,			)
								UpperCAmelCase_		:      Union[str, Any]       	=					output.images
								UpperCAmelCase_		:      Dict       	=					images[0, 255:258, 255:258, -1]

								assert images.shape == (1, 512, 512, 3)
								UpperCAmelCase_		:      Optional[int]       	=					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'''


import qiskit







def 						SCREAMING_SNAKE_CASE(  UpperCamelCase   ,UpperCamelCase  )    ->    qiskit.result.counts.Counts:
	UpperCAmelCase_		:      Tuple       	=					qiskit.Aer.get_backend('aer_simulator'  )

	UpperCAmelCase_		:      List[str]       	=					qiskit.QuantumCircuit(4   ,2  )
	# encode inputs in qubits 0 and 1
	if bita == 1:
		qc_ha.x(0  )
	if bita == 1:
		qc_ha.x(1  )
	qc_ha.barrier()

	# use cnots to write XOR of the inputs on qubit2
	qc_ha.cx(0   ,2  )
	qc_ha.cx(1   ,2  )

	# use ccx / toffoli gate to write AND of the inputs on qubit3
	qc_ha.ccx(0   ,1   ,3  )
	qc_ha.barrier()

	# extract outputs
	qc_ha.measure(2   ,0  )  # extract XOR value
	qc_ha.measure(3   ,1  )  # extract AND value

	# Execute the circuit on the qasm simulator
	UpperCAmelCase_		:      List[str]       	=					qiskit.execute(UpperCamelCase   ,UpperCamelCase   ,shots=1_0_0_0  )

	# Return the histogram data of the results of the experiment
	return job.result().get_counts(UpperCamelCase  )


if __name__ == "__main__":
						lowerCAmelCase__										= half_adder(1, 1)
						print(F'Half Adder Output Qubit Counts: {counts}')






