




import math

import qiskit



def 						lowerCAmelCase		(		_lowerCAmelCase							:   int = 1						,							_lowerCAmelCase							:   int = 1						,							_lowerCAmelCase							:   int = 1	):




 """simple docstring"""







 if (
     isinstance(_lowerCAmelCase						,							_lowerCAmelCase	)
     or isinstance(_lowerCAmelCase						,							_lowerCAmelCase	)
     or isinstance(_lowerCAmelCase						,							_lowerCAmelCase	)
 ):
  raise TypeError("inputs must be integers."	)

 if (input_a < 0) or (input_a < 0) or (carry_in < 0):
  raise ValueError("inputs must be positive."	)

 if (
     (math.floor(_lowerCAmelCase	) != input_a)
     or (math.floor(_lowerCAmelCase	) != input_a)
     or (math.floor(_lowerCAmelCase	) != carry_in)
 ):
  raise ValueError("inputs must be exact integers."	)

 if (input_a > 2) or (input_a > 2) or (carry_in > 2):
  raise ValueError("inputs must be less or equal to 2."	)

 # build registers
 UpperCAmelCase__							 =						qiskit.QuantumRegister(4						,							"qr"	)
 UpperCAmelCase__							 =						qiskit.ClassicalRegister(2						,							"cr"	)
 # list the entries
 UpperCAmelCase__							 =						[input_a, input_a, carry_in]

 UpperCAmelCase__							 =						qiskit.QuantumCircuit(_lowerCAmelCase						,							_lowerCAmelCase	)

 for i in range(0						,							3	):
  if entry[i] == 2:
   quantum_circuit.h(_lowerCAmelCase	)  # for hadamard entries
  elif entry[i] == 1:
   quantum_circuit.x(_lowerCAmelCase	)  # for 1 entries
  elif entry[i] == 0:
   quantum_circuit.i(_lowerCAmelCase	)  # for 0 entries

    # build the circuit
 quantum_circuit.ccx(0						,							1						,							3	)  # ccx = toffoli gate
 quantum_circuit.cx(0						,							1	)
 quantum_circuit.ccx(1						,							2						,							3	)
 quantum_circuit.cx(1						,							2	)
 quantum_circuit.cx(0						,							1	)

 quantum_circuit.measure([2, 3]						,							_lowerCAmelCase	)  # measure the last two qbits

 UpperCAmelCase__							 =						qiskit.Aer.get_backend("aer_simulator"	)
 UpperCAmelCase__							 =						qiskit.execute(_lowerCAmelCase						,							_lowerCAmelCase						,							shots=1000	)

 return job.result().get_counts(_lowerCAmelCase	)


if __name__ == "__main__":
    print(F'''Total sum count for state is: {quantum_full_adder(1, 1, 1)}''')











import random
import unittest

import torch

from diffusers import IFInpaintingSuperResolutionPipeline
from diffusers.utils import floats_tensor
from diffusers.utils.import_utils import is_xformers_available
from diffusers.utils.testing_utils import skip_mps, torch_device

from ..pipeline_params import (
    TEXT_GUIDED_IMAGE_INPAINTING_BATCH_PARAMS,
    TEXT_GUIDED_IMAGE_INPAINTING_PARAMS,
)
from ..test_pipelines_common import PipelineTesterMixin
from . import IFPipelineTesterMixin
@skip_mps
class 			_UpperCamelCase      (				lowerCAmelCase	,       lowerCAmelCase	,       unittest.TestCase		):
      UpperCAmelCase_        =		IFInpaintingSuperResolutionPipeline
      UpperCAmelCase_        =		TEXT_GUIDED_IMAGE_INPAINTING_PARAMS - {"""width""", """height"""}
      UpperCAmelCase_        =		TEXT_GUIDED_IMAGE_INPAINTING_BATCH_PARAMS.union({"""original_image"""}		)
      UpperCAmelCase_        =		PipelineTesterMixin.required_optional_params - {"""latents"""}
      def 	UpperCAmelCase_						(			self   :str      )     ->			Optional[Any]:
       return self._get_superresolution_dummy_components()
      def 	UpperCAmelCase_						(			self   :List[str] ,      lowerCamelCase   :Dict ,      lowerCamelCase   :Optional[Any]=0      )     ->			int:
       if str(lowerCamelCase      ).startswith("mps"      ):
        UpperCAmelCase__							 =						torch.manual_seed(lowerCamelCase      )
       else:
        UpperCAmelCase__							 =						torch.Generator(device=lowerCamelCase      ).manual_seed(lowerCamelCase      )

       UpperCAmelCase__							 =						floats_tensor((1, 3, 16, 16) ,      rng=random.Random(lowerCamelCase      )      ).to(lowerCamelCase      )
       UpperCAmelCase__							 =						floats_tensor((1, 3, 32, 32) ,      rng=random.Random(lowerCamelCase      )      ).to(lowerCamelCase      )
       UpperCAmelCase__							 =						floats_tensor((1, 3, 32, 32) ,      rng=random.Random(lowerCamelCase      )      ).to(lowerCamelCase      )

       UpperCAmelCase__							 =						{
           "prompt": "A painting of a squirrel eating a burger",
           "image": image,
           "original_image": original_image,
           "mask_image": mask_image,
           "generator": generator,
           "num_inference_steps": 2,
           "output_type": "numpy",
       }

       return inputs
      @unittest.skipIf(
          torch_device != "cuda" or not is_xformers_available() ,      reason="XFormers attention is only available with CUDA and `xformers` installed" ,      )
      def 	UpperCAmelCase_						(			self   :Union[str, Any]      )     ->			Dict:
       self._test_xformers_attention_forwardGenerator_pass(expected_max_diff=1e-3      )
      def 	UpperCAmelCase_						(			self   :List[str]      )     ->			Dict:
       self._test_save_load_optional_components()
      @unittest.skipIf(torch_device != "cuda" ,      reason="float16 requires CUDA"      )
      def 	UpperCAmelCase_						(			self   :Tuple      )     ->			Dict:
       # Due to non-determinism in save load of the hf-internal-testing/tiny-random-t5 text encoder
       super().test_save_load_floataa(expected_max_diff=1e-1      )
      def 	UpperCAmelCase_						(			self   :Dict      )     ->			str:
       self._test_attention_slicing_forward_pass(expected_max_diff=1e-2      )
      def 	UpperCAmelCase_						(			self   :Dict      )     ->			str:
       self._test_save_load_local()







      def 	UpperCAmelCase_						(			self   :List[str]      )     ->			List[str]:
       self._test_inference_batch_single_identical(
           expected_max_diff=1e-2 ,      )





