class_docstr: Test that the transform integrates well with QNodes.
docstr: Test that a new wire is added for every measurement after which
  the wire is reused.
docstr_tok: ["Test","that","a","new","wire","is","added","for","every","measurement","after","which","the","wire","is","reused","."]
code: def test_new_wires_after_reuse(self, mocker):
      """Test that a new wire is added for every measurement after which
      the wire is reused."""
      dev = qml.device("default.qubit", wires=4)
      spy = mocker.spy(qml.defer_measurements, "_transform")
  
      @qml.qnode(dev)
      def qnode1(phi, theta):
          qml.RX(phi, 0)
          m0 = qml.measure(
              0, reset=True
          )  # Reused measurement, one new wire added
          qml.cond(m0, qml.Hadamard)(1)
          m1 = qml.measure(1)  # No reuse
          qml.RY(theta, 2)
          qml.cond(m1, qml.RY)(-theta, 2)
          return qml.expval(qml.PauliZ(2))
  
      res1 = qnode1(np.pi / 4, 3 * np.pi / 4)
  
      @qml.qnode(dev)
      def qnode2(phi, theta):
          qml.RX(phi, 0)
          m0 = qml.measure(0)  # No reuse
          qml.cond(m0, qml.Hadamard)(1)
          m1 = qml.measure(1)  # No reuse
          qml.RY(theta, 2)
          qml.cond(m1, qml.RY)(-theta, 2)
          return qml.expval(qml.PauliZ(2))
  
      res2 = qnode2(np.pi / 4, 3 * np.pi / 4)
  
      assert spy.call_count == 2
  
      deferred_tapes1, _ = qml.defer_measurements(qnode1.qtape)
      deferred_tape1 = deferred_tapes1[0]
      assert len(deferred_tape1.wires) == 4
      assert len(deferred_tape1.operations) == 6
  
      assert np.allclose(res1, res2)
  
      deferred_tapes2, _ = qml.defer_measurements(qnode2.qtape)
      deferred_tape2 = deferred_tapes2[0]
      assert len(deferred_tape2.wires) == 3
      assert len(deferred_tape2.operations) == 4
  
imports: import math
  import pytest
  import pennylane
  from pennylane.measurements import MidMeasureMP, MeasurementValue
  import pennylane.numpy
  from pennylane.devices import DefaultQubit
label_desc: Use image node_id 5 for calling the TestQNode obj's underlying member method code with example usage: obj.test_new_wires_after_reuse(mocker) and returns: qml, qml