How to measure the output probabilities?

I have a code of 10 qubits. How to know the probability of each qubit?
The code is:

qml.Identity(wires=0)
qml.Identity(wires=1)
qml.Identity(wires=2)
qml.Identity(wires=3)
qml.Identity(wires=4)
qml.Identity(wires=5)
qml.Identity(wires=6)
qml.Identity(wires=7)
qml.Hadamard(wires=8)
qml.Hadamard(wires=9)
qml.Barrier()
for idx, px_value in enumerate(phi[::-1]):
if (px_value==‘1’):
qml.Toffoli(wires=[9,8,idx])
qml.Barrier()
measurement = [qml.expval(qml.PauliZ(i)) for i in range(wires)]
return measurement

I want to return both probability and measurement. How to do that also?

Hey @mass_of_15,

To return the probability of each qubit (10 in your case), you can return qml.probs(wires=range(10)). In addition, QNodes can return multiple measurements. Consider this code example:

qml.enable_return()

dev = qml.device("lightning.qubit", wires=2)

@qml.qnode(dev)
def circuit():
     qml.Hadamard(0)
     qml.Hadamard(1)
     return qml.probs(wires=range(2)), qml.expval(qml.PauliX(0))
 
circuit()
# Output: (tensor([0.5, 0.5, 0. , 0. ], requires_grad=True), tensor(1., requires_grad=True))    

All of the available measurements and use cases can be found here.

Let me know if that helps!