






"""simple docstring"""


import math

import qiskit


def        UpperCAmelCase      (					a__ = 1     ,      a__ = 1     ,      a__ = 1 ):





						'''simple docstring'''






						if (
						    isinstance(a__     ,      a__ )
						    or isinstance(a__     ,      a__ )
						    or isinstance(a__     ,      a__ )
						):
												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(a__ ) != input_a)
						    or (math.floor(a__ ) != input_a)
						    or (math.floor(a__ ) != 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
						lowerCAmelCase   :str						=			qiskit.QuantumRegister(4     ,      'qr' )
						lowerCAmelCase   :Optional[int]						=			qiskit.ClassicalRegister(2     ,      'cr' )
						# list the entries
						lowerCAmelCase   :List[Any]						=			[input_a, input_a, carry_in]

						lowerCAmelCase   :List[str]						=			qiskit.QuantumCircuit(a__     ,      a__ )

						for i in range(0     ,      3 ):
												if entry[i] == 2:
																		quantum_circuit.h(a__ )  # for hadamard entries
												elif entry[i] == 1:
																		quantum_circuit.x(a__ )  # for 1 entries
												elif entry[i] == 0:
																		quantum_circuit.i(a__ )  # 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]     ,      a__ )  # measure the last two qbits

						lowerCAmelCase   :Tuple						=			qiskit.Aer.get_backend('aer_simulator' )
						lowerCAmelCase   :List[str]						=			qiskit.execute(a__     ,      a__     ,      shots=10_00 )

						return job.result().get_counts(a__ )


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







"""simple docstring"""


import argparse

import torch

from transformers import MobileBertConfig, MobileBertForPreTraining, load_tf_weights_in_mobilebert
from transformers.utils import logging


logging.set_verbosity_info()


def        UpperCAmelCase      (					a__     ,      a__     ,      a__ ):





						'''simple docstring'''






						lowerCAmelCase   :Tuple						=			MobileBertConfig.from_json_file(a__ )
						print(F"""Building PyTorch model from configuration: {config}""" )
						lowerCAmelCase   :Tuple						=			MobileBertForPreTraining(a__ )
						# Load weights from tf checkpoint
						lowerCAmelCase   :Any						=			load_tf_weights_in_mobilebert(a__     ,      a__     ,      a__ )
						# Save pytorch-model
						print(F"""Save PyTorch model to {pytorch_dump_path}""" )
						torch.save(model.state_dict()     ,      a__ )


if __name__ == "__main__":
		__SCREAMING_SNAKE_CASE   =   argparse.ArgumentParser()
		# Required parameters
		parser.add_argument(
		    '--tf_checkpoint_path', default=None, type=str, required=True, help='Path to the TensorFlow checkpoint path.'
		)
		parser.add_argument(
		    '--mobilebert_config_file',
		    default=None,
		    type=str,
		    required=True,
		    help=(
		        'The config json file corresponding to the pre-trained MobileBERT model. \n'
		        'This specifies the model architecture.'
		    ),
		)
		parser.add_argument(
		    '--pytorch_dump_path', default=None, type=str, required=True, help='Path to the output PyTorch model.'
		)
		__SCREAMING_SNAKE_CASE   =   parser.parse_args()
		convert_tf_checkpoint_to_pytorch(args.tf_checkpoint_path, args.mobilebert_config_file, args.pytorch_dump_path)