class_docstr: Test that the transform integrates well with QNodes.
docstr: Test that a qnode with mid-circuit measurements with postselection
  is transformed correctly by defer_measurements
docstr_tok: ["Test","that","a","qnode","with","mid-circuit","measurements","with","postselection","is","transformed","correctly","by","defer_measurements"]
code: def test_multiple_postselection_qnode(
      self, phi, theta, shots, tol, tol_stochastic
  ):
      """Test that a qnode with mid-circuit measurements with postselection
      is transformed correctly by defer_measurements"""
      dev = DefaultQubit()
  
      # Initializing mid circuit measurements here so that id can be controlled (affects
      # wire ordering for qml.cond)
      mp0 = MidMeasureMP(wires=0, postselect=0, id=0)
      mv0 = MeasurementValue([mp0], lambda v: v)
      mp1 = MidMeasureMP(wires=1, postselect=0, id=1)
      mv1 = MeasurementValue([mp1], lambda v: v)
      mp2 = MidMeasureMP(wires=2, reset=True, postselect=1, id=2)
      mv2 = MeasurementValue([mp2], lambda v: v)
  
      @qml.qnode(dev)
      @qml.defer_measurements
      def circ1(phi, theta):
          qml.RX(phi, 0)
          qml.apply(mp0)
          qml.CNOT([0, 1])
          qml.apply(mp1)
          qml.cond(~(mv0 & mv1), qml.RY)(theta, wires=2)
          qml.apply(mp2)
          qml.cond(mv2, qml.PauliX)(1)
          return qml.probs(wires=[0, 1, 2])
  
      @qml.qnode(dev)
      def circ2():
          # To add wire 0 to tape
          qml.Identity(0)
          qml.PauliX(1)
          qml.Identity(2)
          return qml.probs(wires=[0, 1, 2])
  
      atol = tol if shots is None else tol_stochastic
      assert np.allclose(
          circ1(phi, theta, shots=shots), circ2(), atol=atol, rtol=0
      )
  
      expected_circuit = [
          qml.RX(phi, wires=0),
          qml.Projector([0], wires=0),
          qml.CNOT([0, 3]),
          qml.CNOT([0, 1]),
          qml.Projector([0], wires=1),
          qml.CNOT([1, 4]),
          qml.ops.Controlled(
              qml.RY(theta, wires=[2]),
              control_wires=[3, 4],
              control_values=[False, False],
          ),
          qml.ops.Controlled(
              qml.RY(theta, wires=[2]),
              control_wires=[3, 4],
              control_values=[False, True],
          ),
          qml.ops.Controlled(
              qml.RY(theta, wires=[2]),
              control_wires=[3, 4],
              control_values=[True, False],
          ),
          qml.Projector([1], wires=2),
          qml.CNOT([2, 5]),
          qml.PauliX(2),
          qml.CNOT([5, 1]),
          qml.probs(wires=[0, 1, 2]),
      ]
  
      for op, expected_op in zip(circ1.qtape, expected_circuit):
          assert qml.equal(op, expected_op)
  
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 7 for calling the TestQNode obj's underlying member method code with example usage: obj.test_multiple_postselection_qnode(phi, theta, shots, tol, tol_stochastic) and returns: qml, qml