




'''simple docstring'''


import qiskit
def 						snake_case_       (UpperCamelCase			:    int					,		UpperCamelCase			:    int ):





							'''simple docstring'''


							_a      	=							qiskit.Aer.get_backend('''aer_simulator''' )

							_a      	=							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
							_a      	=							qiskit.execute(UpperCamelCase					,		UpperCamelCase					,		shots=1000 )

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


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







'''simple docstring'''


import unittest

from transformers import is_flax_available
from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, require_torch, slow


if is_flax_available():
				import optax
				from flax.training.common_utils import onehot

				from transformers import AutoTokenizer, FlaxMTaForConditionalGeneration
				from transformers.models.ta.modeling_flax_ta import shift_tokens_right

@require_torch
@require_sentencepiece
@require_tokenizers
@require_flax
class      A       (						unittest.TestCase       ):







							@slow
							def   __lowerCAmelCase     (    self			:    List[Any]   )     ->				Union[str, Any]:


														"""simple docstring"""


														_a      	=							FlaxMTaForConditionalGeneration.from_pretrained('''google/mt5-small'''   )
														_a      	=							AutoTokenizer.from_pretrained('''google/mt5-small'''   )

														_a      	=							tokenizer('''Hello there'''				,     return_tensors='''np'''   ).input_ids
														_a      	=							tokenizer('''Hi I am'''				,     return_tensors='''np'''   ).input_ids

														_a      	=							shift_tokens_right(lowerCAmelCase_				,     model.config.pad_token_id				,     model.config.decoder_start_token_id   )

														_a      	=							model(lowerCAmelCase_				,     decoder_input_ids=lowerCAmelCase_   ).logits
														_a      	=							optax.softmax_cross_entropy(lowerCAmelCase_				,     onehot(lowerCAmelCase_				,     logits.shape[-1]   )   ).mean()

														_a      	=							-(labels.shape[-1] * loss.item())

														_a      	=							-8_4.9_1_2_7
														self.assertTrue(abs(mtf_score - EXPECTED_SCORE   ) < 1e-4   )

