






'''simple docstring'''







import unittest

import numpy as np
import torch

from diffusers import ScoreSdeVePipeline, ScoreSdeVeScheduler, UNetaDModel
from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device


enable_full_determinism()




class 		UpperCamelCase__     (unittest.TestCase      ):




		'''simple docstring'''





		@property
		def       UpperCamelCase_       (   self							):
								torch.manual_seed(0							)
								lowerCamelCase__								=	UNetaDModel(
								    block_out_channels=(32, 64) ,layers_per_block=2 ,sample_size=32 ,in_channels=3 ,out_channels=3 ,down_block_types=("""DownBlock2D""", """AttnDownBlock2D""") ,up_block_types=("""AttnUpBlock2D""", """UpBlock2D""") ,)
								return model






		def       UpperCamelCase_       (   self							):
								lowerCamelCase__								=	self.dummy_uncond_unet
								lowerCamelCase__								=	ScoreSdeVeScheduler()

								lowerCamelCase__								=	ScoreSdeVePipeline(unet=_lowerCAmelCase ,scheduler=_lowerCAmelCase							)
								sde_ve.to(_lowerCAmelCase							)
								sde_ve.set_progress_bar_config(disable=_lowerCAmelCase							)

								lowerCamelCase__								=	torch.manual_seed(0							)
								lowerCamelCase__								=	sde_ve(num_inference_steps=2 ,output_type="""numpy""" ,generator=_lowerCAmelCase							).images

								lowerCamelCase__								=	torch.manual_seed(0							)
								lowerCamelCase__								=	sde_ve(num_inference_steps=2 ,output_type="""numpy""" ,generator=_lowerCAmelCase ,return_dict=_lowerCAmelCase							)[
								    0
								]

								lowerCamelCase__								=	image[0, -3:, -3:, -1]
								lowerCamelCase__								=	image_from_tuple[0, -3:, -3:, -1]

								assert image.shape == (1, 32, 32, 3)
								lowerCamelCase__								=	np.array([0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0]							)

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




@slow
@require_torch
class 		UpperCamelCase__     (unittest.TestCase      ):




		'''simple docstring'''





		def       UpperCamelCase_       (   self							):
								lowerCamelCase__								=	"""google/ncsnpp-church-256"""
								lowerCamelCase__								=	UNetaDModel.from_pretrained(_lowerCAmelCase							)

								lowerCamelCase__								=	ScoreSdeVeScheduler.from_pretrained(_lowerCAmelCase							)

								lowerCamelCase__								=	ScoreSdeVePipeline(unet=_lowerCAmelCase ,scheduler=_lowerCAmelCase							)
								sde_ve.to(_lowerCAmelCase							)
								sde_ve.set_progress_bar_config(disable=_lowerCAmelCase							)

								lowerCamelCase__								=	torch.manual_seed(0							)
								lowerCamelCase__								=	sde_ve(num_inference_steps=10 ,output_type="""numpy""" ,generator=_lowerCAmelCase							).images

								lowerCamelCase__								=	image[0, -3:, -3:, -1]

								assert image.shape == (1, 2_56, 2_56, 3)

								lowerCamelCase__								=	np.array([0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0]							)

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





import qiskit


def     lowercase	(    a     , a ):



		'''simple docstring'''




		SCREAMING_SNAKE_CASE_				:int				     =						qiskit.Aer.get_backend("aer_simulator" )

		# Create a Quantum Circuit acting on the q register
		SCREAMING_SNAKE_CASE_				:Union[str, Any]				     =						qiskit.QuantumCircuit(a     , a )

		# Apply X (NOT) Gate to Qubits 0 & 1
		circuit.x(0 )
		circuit.x(1 )

		# Map the quantum measurement to the classical bits
		circuit.measure([0, 1]     , [0, 1] )

		# Execute the circuit on the qasm simulator
		SCREAMING_SNAKE_CASE_				:Any				     =						qiskit.execute(a     , a     , shots=1000 )

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


if __name__ == "__main__":
		SCREAMING_SNAKE_CASE__     					=			single_qubit_measure(2, 2)
		print(F'''Total count for various states are: {counts}''')






