



import qiskit

def        a						(      _UpperCAmelCase							:					int ,   _UpperCAmelCase							:					int						):







		'''simple docstring'''





		__UpperCAmelCase    :     List[str]													=	qiskit.Aer.get_backend('''aer_simulator'''						)

		__UpperCAmelCase    :     Optional[Any]													=	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    :     str													=	qiskit.execute(_UpperCAmelCase ,   _UpperCAmelCase ,   shots=10_00						)

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


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










import json
import os
import tempfile

from transformers.testing_utils import check_json_file_has_correct_format

class 		UpperCAmelCase__			:




			'''simple docstring'''






			UpperCamelCase									=       None




			def  snake_case__     (   self							: List[str] ):
					'''simple docstring'''





					__UpperCAmelCase    :     List[Any]													=	self.feature_extraction_class(**self.feat_extract_dict )
					__UpperCAmelCase    :     Optional[int]													=	json.loads(feat_extract.to_json_string() )
					for key, value in self.feat_extract_dict.items():
							self.assertEqual(obj[key]       ,       a_ )




			def  snake_case__     (   self							: Any ):
					'''simple docstring'''





					__UpperCAmelCase    :     str													=	self.feature_extraction_class(**self.feat_extract_dict )

					with tempfile.TemporaryDirectory() as tmpdirname:
							__UpperCAmelCase    :     Union[str, Any]													=	os.path.join(a_       ,       '''feat_extract.json''' )
							feat_extract_first.to_json_file(a_ )
							__UpperCAmelCase    :     Any													=	self.feature_extraction_class.from_json_file(a_ )

					self.assertEqual(feat_extract_second.to_dict()       ,       feat_extract_first.to_dict() )




			def  snake_case__     (   self							: Optional[int] ):
					'''simple docstring'''





					__UpperCAmelCase    :     Tuple													=	self.feature_extraction_class(**self.feat_extract_dict )

					with tempfile.TemporaryDirectory() as tmpdirname:
							__UpperCAmelCase    :     List[str]													=	feat_extract_first.save_pretrained(a_ )[0]
							check_json_file_has_correct_format(a_ )
							__UpperCAmelCase    :     Optional[Any]													=	self.feature_extraction_class.from_pretrained(a_ )

					self.assertEqual(feat_extract_second.to_dict()       ,       feat_extract_first.to_dict() )




			def  snake_case__     (   self							: Dict ):
					'''simple docstring'''





					__UpperCAmelCase    :     int													=	self.feature_extraction_class()
					self.assertIsNotNone(a_ )





