class_docstr: Test that check the main functionalities of the `undo_swaps` transform
class_docstr_tok: ["Test","that","check","the","main","functionalities","of","the","`","undo_swaps","`","transform"]
docstr: Test that the decorator works on a QNode.
docstr_tok: ["Test","that","the","decorator","works","on","a","QNode","."]
code: def test_decorator(self, mocker):
      """Test that the decorator works on a QNode."""
  
      spy = mocker.spy(dev, "execute")
  
      @undo_swaps
      @qml.qnode(dev)
      def qfunc():
          qml.Hadamard(wires=0)
          qml.PauliX(wires=1)
          qml.SWAP(wires=[0, 1])
          qml.SWAP(wires=[0, 2])
          qml.PauliY(wires=0)
          return qml.expval(qml.PauliZ(0))
  
      assert np.allclose(qfunc(), -1)
      [[tape]], _ = spy.call_args
      assert tape.operations == [
          qml.Hadamard(1),
          qml.PauliX(2),
          qml.PauliY(0),
      ]
  
file_path: pennylane/tests/transforms/test_optimization/test_undo_swaps.py
imports: import pytest
  from utils import compare_operation_lists
  import pennylane
  from pennylane import numpy
  from pennylane.wires import Wires
  from pennylane.transforms.optimization import undo_swaps
label_desc: Use image node_id 6 for calling the TestUndoSwaps obj's underlying member method code with example usage: obj.test_decorator(mocker) and returns: qml