class_docstr: Integration tests to verify outputs of compilation pipelines.
class_docstr_tok: ["Integration","tests","to","verify","outputs","of","compilation","pipelines","."]
docstr: Test that functions with templates are correctly expanded and compiled.
docstr_tok: ["Test","that","functions","with","templates","are","correctly","expanded","and","compiled","."]
code: def test_compile_template(self):
      """Test that functions with templates are correctly expanded and compiled."""
  
      # Push commuting gates to the right and merging rotations gives a circuit
      # with alternating RX and CNOT gates
      # pylint: disable=expression-not-assigned
      def qfunc(x, params):
          qml.templates.AngleEmbedding(x, wires=range(3))
          qml.adjoint(
              qml.adjoint(
                  qml.templates.BasicEntanglerLayers(
                      params, wires=range(3)
                  )
              )
          ) ** 2
          return qml.expval(qml.PauliZ(wires=2))
  
      dev = qml.device("default.qubit", wires=3)
      qnode = qml.QNode(qfunc, dev)
  
      pipeline = [commute_controlled, merge_rotations]
      transformed_qfunc = compile(qfunc, pipeline=pipeline)
      transformed_qnode = qml.QNode(transformed_qfunc, dev)
  
      x = np.array([0.1, 0.2, 0.3])
      params = np.ones((2, 3))
  
      original_result = qnode(x, params)
      transformed_result = transformed_qnode(x, params)
      assert np.allclose(original_result, transformed_result)
  
      names_expected = ["RX", "CNOT"] * 12
      wires_expected = [
          Wires(0),
          Wires([0, 1]),
          Wires(1),
          Wires([1, 2]),
          Wires(2),
          Wires([2, 0]),
      ] * 4
  
      compare_operation_lists(
          transformed_qnode.qtape.operations,
          names_expected,
          wires_expected,
      )
  
imports: from functools import partial
  import pytest
  from test_optimization.utils import compare_operation_lists
  import pennylane
  from pennylane import numpy
  from pennylane.wires import Wires
  from pennylane.transforms.compile import compile
  from pennylane.transforms import unitary_to_rot
  from pennylane.transforms.optimization import cancel_inverses, commute_controlled, merge_rotations, single_qubit_fusion
  from pennylane.transforms.optimization.optimization_utils import _fuse_global_phases
label_desc: Use image node_id 8 for calling the TestCompileIntegration obj's underlying member method code with example usage: obj.test_compile_template() and returns: qml