class_docstr: Test that pulse_odegen integrates correctly with QNodes.
class_docstr_tok: ["Test","that","pulse_odegen","integrates","correctly","with","QNodes","."]
docstr: Test that an advanced qnode can be differentiated with pulse_odegen.
docstr_tok: ["Test","that","an","advanced","qnode","can","be","differentiated","with","pulse_odegen","."]
code: def test_advanced_qnode(self, dev_name):
      """Test that an advanced qnode can be differentiated with pulse_odegen."""
      import jax
      import jax.numpy as jnp
  
      jax.config.update("jax_enable_x64", True)
  
      params = [
          jnp.array(0.21),
          jnp.array(-0.171),
          jnp.array([0.05, 0.03, -0.1]),
      ]
      dev = qml.device(dev_name, wires=2)
      ham = (
          qml.pulse.constant * X(0)
          + (lambda p, t: jnp.sin(p * t)) * Z(0)
          + jnp.polyval * (Y(0) @ Y(1))
      )
  
      def ansatz(params):
          qml.evolve(ham)(params, 0.1)
          return qml.expval(Y(0) @ X(1))
  
      qnode_pulse_grad = qml.QNode(
          ansatz,
          dev,
          interface="jax",
          diff_method=pulse_odegen,
      )
      qnode_backprop = qml.QNode(ansatz, dev, interface="jax")
  
      with qml.Tracker(dev) as tracker:
          grad_pulse_grad = jax.grad(qnode_pulse_grad)(params)
      assert (
          tracker.totals["executions"] == 1 + 12
      )  # one forward execution, dim(DLA)=6
      grad_backprop = jax.grad(qnode_backprop)(params)
  
      assert all(
          qml.math.allclose(r, e, atol=1e-7)
          for r, e in zip(grad_pulse_grad, grad_backprop)
      )
  
imports: import copy
  import pytest
  import numpy
  import pennylane
  from pennylane import numpy
  from pennylane.ops.qubit.special_unitary import pauli_basis_matrices, pauli_basis_strings
  from pennylane.math import expand_matrix
  from pennylane.gradients.pulse_gradient_odegen import _generate_tapes_and_coeffs, pulse_odegen, _insert_op, _nonzero_coeffs_and_words, _one_parameter_generators, _one_parameter_paulirot_coeffs, _parshift_and_contract
label_desc: Use image node_id 6 for calling the TestPulseOdegenIntegration obj's underlying member method code with example usage: obj.test_advanced_qnode(dev_name) and returns: qml