class_docstr: Testing the tracking capabilities of DefaultQubit.
class_docstr_tok: ["Testing","the","tracking","capabilities","of","DefaultQubit","."]
docstr: Test the number of times the device is executed over a QNode's
  lifetime is tracked by the device's tracker.
docstr_tok: ["Test","the","number","of","times","the","device","is","executed","over","a","QNode's","lifetime","is","tracked","by","the","device","'s","tracker","."]
code: def test_tracking_batched_execution(self):
      """Test the number of times the device is executed over a QNode's
      lifetime is tracked by the device's tracker."""
  
      dev_1 = qml.device("default.qubit", wires=2)
  
      def circuit_1(x, y):
          qml.RX(x, wires=[0])
          qml.RY(y, wires=[1])
          qml.CNOT(wires=[0, 1])
          return qml.expval(qml.PauliZ(0) @ qml.PauliX(1))
  
      node_1 = qml.QNode(circuit_1, dev_1)
      num_evals_1 = 10
  
      with qml.Tracker(dev_1, persistent=True) as tracker1:
          for _ in range(num_evals_1):
              node_1(0.432, np.array([0.12, 0.5, 3.2]))
      assert tracker1.totals["executions"] == 3 * num_evals_1
      assert tracker1.totals["simulations"] == num_evals_1
  
      # test a second instance of a default qubit device
      dev_2 = qml.device("default.qubit", wires=2)
  
      def circuit_2(x):
          qml.RX(x, wires=[0])
          qml.CNOT(wires=[0, 1])
          return qml.expval(qml.PauliZ(0) @ qml.PauliX(1))
  
      node_2 = qml.QNode(circuit_2, dev_2)
      num_evals_2 = 5
  
      with qml.Tracker(dev_2) as tracker2:
          for _ in range(num_evals_2):
              node_2(np.array([0.432, 0.61, 8.2]))
      assert tracker2.totals["simulations"] == num_evals_2
      assert tracker2.totals["executions"] == 3 * num_evals_2
  
      # test a new circuit on an existing instance of a qubit device
      def circuit_3(y):
          qml.RY(y, wires=[1])
          qml.CNOT(wires=[0, 1])
          return qml.expval(qml.PauliZ(0) @ qml.PauliX(1))
  
      node_3 = qml.QNode(circuit_3, dev_1)
      num_evals_3 = 7
  
      with tracker1:
          for _ in range(num_evals_3):
              node_3(np.array([0.12, 1.214]))
      assert tracker1.totals["simulations"] == num_evals_1 + num_evals_3
      assert (
          tracker1.totals["executions"]
          == 3 * num_evals_1 + 2 * num_evals_3
      )
  
file_path: pennylane/tests/devices/test_default_qubit_tracking.py
imports: import pytest
  import numpy
  import pennylane
  from pennylane.resource import Resources
  from pennylane.devices import ExecutionConfig
label_desc: Use image node_id 6 for calling the TestTracking obj's underlying member method code with example usage: obj.test_tracking_batched_execution() and returns: qml, qml, qml