class_docstr: Pattern matching tests.
class_docstr_tok: ["Pattern","matching","tests","."]
docstr: Test for a pattern and circuit with a diamond shape graph.
docstr_tok: ["Test","for","a","pattern","and","circuit","with","a","diamond","shape","graph","."]
code: def test_forward_diamond_pattern_and_circuit(self):
      """Test for a pattern and circuit with a diamond shape graph."""
  
      def circuit():
          qml.CNOT(wires=[0, 2])
          qml.S(wires=[1])
          qml.Hadamard(wires=3)
          qml.CNOT(wires=[0, 3])
          qml.S(wires=1)
          qml.Hadamard(wires=2)
          qml.Hadamard(wires=0)
          qml.CNOT(wires=[1, 2])
          qml.Hadamard(wires=3)
          qml.CNOT(wires=[0, 2])
          qml.CNOT(wires=[1, 3])
          qml.S(wires=0)
          qml.S(wires=2)
          qml.Hadamard(wires=3)
          return qml.expval(qml.PauliX(wires=0))
  
      with qml.queuing.AnnotatedQueue() as q_pattern:
          qml.S(wires=0)
          qml.Hadamard(wires=0)
          qml.Hadamard(wires=1)
          qml.T(wires=1)
          qml.T(wires=1)
          qml.CNOT(wires=[0, 1])
  
      pattern = qml.tape.QuantumScript.from_queue(q_pattern)
      circuit_dag = commutation_dag(circuit)()
      pattern_dag = commutation_dag(pattern)
  
      max_matches = [
          x.match for x in pattern_matching(circuit_dag, pattern_dag)
      ]
      assert [[1, 6], [5, 9]] in max_matches
  
imports: import pytest
  import pennylane
  import pennylane.numpy
  from pennylane.transforms.commutation_dag import commutation_dag
  from pennylane.transforms.optimization.pattern_matching import pattern_matching, pattern_matching_optimization, ForwardMatch, BackwardMatch, _update_qubits
label_desc: Use image node_id 3 for calling the TestPatternMatching obj's underlying member method code with example usage: obj.test_forward_diamond_pattern_and_circuit() and returns: qml