#imports
from qiskit_ionq import IonQProvider
ionq_provider = IonQProvider(token='API-Key-goes-here')
import numpy as np

from qiskit import QuantumCircuit, execute, Aer
from qiskit.tools.visualization import plot_histogram, array_to_latex
from qiskit.extensions import UnitaryGate


BV=QuantumCircuit(4,3)
BV.h(0)
BV.h(1)
BV.h(2)
BV.h(3)
BV.z(3)
BV.barrier()
BV.draw()

BV.cx(0,3)
BV.barrier()
BV.draw()

BV.h(0)
BV.h(1)
BV.h(2)
BV.measure(0,0)
BV.measure(1,1)
BV.measure(2,2)
BV.draw()

backend = ionq_provider.get_backend("ionq_simulator")#choose your backend
job = execute(BV, backend,shot=50000) #get the job object

    
result = job.result() # get result object
counts = result.get_counts() #get the counts dictionary
fig=plot_histogram(counts) #plot the histogram of the counts    
ax = fig.axes[0]
fig 

