



import numpy as np
import qiskit
from qiskit import Aer, ClassicalRegister, QuantumCircuit, QuantumRegister, execute




def 						UpperCAmelCase (    _lowerCamelCase = np.pi / 2			,     _lowerCamelCase = np.pi / 2			,     _lowerCamelCase = np.pi / 2     ):
			A				:       Optional[int]														=    QuantumRegister(3			,     "qr"     )  # Define the number of quantum bits
			A				:       int														=    ClassicalRegister(1			,     "cr"     )  # Define the number of classical bits

			A				:       Union[str, Any]														=    QuantumCircuit(_UpperCAmelCase			,     _UpperCAmelCase     )  # Define the quantum circuit.

			# Build the circuit
			quantum_circuit.u(_UpperCAmelCase			,     _UpperCAmelCase			,     _UpperCAmelCase			,     0     )  # Quantum State to teleport
			quantum_circuit.h(1     )  # add hadamard gate
			quantum_circuit.cx(
			    1			,     2     )  # add control gate with qubit 1 as control and 2 as target.
			quantum_circuit.cx(0			,     1     )
			quantum_circuit.h(0     )
			quantum_circuit.cz(0			,     2     )  # add control z gate.
			quantum_circuit.cx(1			,     2     )

			quantum_circuit.measure([2]			,     [0]     )  # measure the qubit.

			# Simulate the circuit using qasm simulator
			A				:       Union[str, Any]														=    Aer.get_backend("aer_simulator"     )
			A				:       int														=    execute(_UpperCAmelCase			,     _UpperCAmelCase			,     shots=1000     )

			return job.result().get_counts(_UpperCAmelCase     )


if __name__ == "__main__":
							print(
							    """Total count for teleported state is: """
							    F"""{quantum_teleportation(np.pi/2, np.pi/2, np.pi/2)}"""
							)




import json
import logging
import os
import subprocess
from argparse import ArgumentParser


__A       =logging.getLogger(__name__)

def 			a		( ):







		'''simple docstring'''





		__UpperCAmelCase       :	Dict						=      ArgumentParser()
		__UpperCAmelCase				,   __UpperCAmelCase       :	int						=      parser.parse_known_args()
		for arg in unknown:
				if arg.startswith(('''-''', '''--''')		):
						parser.add_argument(arg.split('''='''		)[0]		)

		return parser.parse_args()

def 			a		( ):







		'''simple docstring'''





		__UpperCAmelCase       :	List[Any]						=      parse_args()
		__UpperCAmelCase       :	Tuple						=      88_88
		__UpperCAmelCase       :	Any						=      int(os.environ['''SM_NUM_GPUS''']		)
		__UpperCAmelCase       :	Optional[int]						=      json.loads(os.environ['''SM_HOSTS''']		)
		__UpperCAmelCase       :	int						=      len(_UpperCAmelCase		)
		__UpperCAmelCase       :	Optional[Any]						=      os.environ['''SM_CURRENT_HOST''']
		__UpperCAmelCase       :	List[str]						=      hosts.index(_UpperCAmelCase		)
		__UpperCAmelCase       :	Dict						=      '''INFO'''

		if num_nodes > 1:
				__UpperCAmelCase       :	Tuple						=      f'python -m torch.distributed.launch \\n                --nnodes={num_nodes}  \\n                --node_rank={rank}  \\n                --nproc_per_node={num_gpus}  \\n                --master_addr={hosts[0]}  \\n                --master_port={port} \\n                ./run_glue.py \\n                {"".join(["nested fstring" for parameter,value in args.__dict__.items()]		)}'
		else:
				__UpperCAmelCase       :	Dict						=      f'python -m torch.distributed.launch \\n            --nproc_per_node={num_gpus}  \\n            ./run_glue.py \\n            {"".join(["nested fstring" for parameter,value in args.__dict__.items()]		)}'
		try:
				subprocess.run(_UpperCAmelCase					,  shell=_UpperCAmelCase		)
		except Exception as e:
				logger.info(_UpperCAmelCase		)


if __name__ == "__main__":
				main()





