class_docstr: Tests templates being conditioned on mid-circuit measurement outcomes.
docstr: Test layers conditioned on mid-circuit measurement outcomes.
docstr_tok: ["Test","layers","conditioned","on","mid-circuit","measurement","outcomes","."]
code: def test_layers(self, template):
      """Test layers conditioned on mid-circuit measurement outcomes."""
      dev = qml.device("default.qubit", wires=4)
  
      num_wires = 2
  
      @qml.qnode(dev)
      def qnode1(parameters):
          qml.Hadamard(0)
          qml.ctrl(template, control=0)(parameters, wires=range(1, 3))
          return qml.expval(qml.PauliZ(1) @ qml.PauliZ(2))
  
      @qml.qnode(dev)
      @qml.defer_measurements
      def qnode2(parameters):
          qml.Hadamard(0)
          m_0 = qml.measure(0)
          qml.cond(m_0, template)(parameters, wires=range(1, 3))
          return qml.expval(qml.PauliZ(1) @ qml.PauliZ(2))
  
      shape = template.shape(n_layers=2, n_wires=num_wires)
      weights = np.random.random(size=shape)
  
      assert np.allclose(qnode1(weights), qnode2(weights))
  
      assert len(qnode2.qtape.operations) == len(
          qnode1.qtape.operations
      )
      assert len(qnode1.qtape.measurements) == len(
          qnode2.qtape.measurements
      )
  
      # Check the operations
      for op1, op2 in zip(
          qnode1.qtape.operations, qnode2.qtape.operations
      ):
          assert isinstance(op1, type(op2))
          assert np.allclose(op1.data, op2.data)
  
      # Check the measurements
      for op1, op2 in zip(
          qnode1.qtape.measurements, qnode2.qtape.measurements
      ):
          assert isinstance(op1, type(op2))
          assert np.allclose(op1.data, op2.data)
  
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 3 for calling the TestTemplates obj's underlying member method code with example usage: obj.test_layers(template) and returns: qml, qml