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 a template changes correctly with a SWAP.
docstr_tok: ["Test","that","a","template","changes","correctly","with","a","SWAP","."]
code: def test_templates_transform(self):
      """Test that a template changes correctly with a SWAP."""
  
      def qfunc1():
          qml.RX(2, wires=0)
          qml.RY(-3, wires=1)
          qml.QFT(wires=[0, 1, 2])
          qml.SWAP(wires=[1, 2])
          return qml.state()
  
      def qfunc2():
          qml.RX(2, wires=0)
          qml.RY(-3, wires=2)
          qml.QFT(wires=[0, 2, 1])
          return qml.state()
  
      transformed_qfunc = undo_swaps(qfunc1)
  
      tape1 = qml.tape.make_qscript(transformed_qfunc)()
      res1 = qml.device("default.qubit", wires=3).execute(tape1)
  
      tape2 = qml.tape.make_qscript(qfunc2)()
      res2 = qml.device("default.qubit", wires=3).execute(tape2)
  
      assert np.allclose(res1, res2)
  
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 4 for calling the TestUndoSwaps obj's underlying member method code with example usage: obj.test_templates_transform() and returns: qml, qml