class_docstr: Test that the QDrift template integrates well with the rest of PennyLane
class_docstr_tok: ["Test","that","the","QDrift","template","integrates","well","with","the","rest","of","PennyLane"]
docstr: Test that the gradient is computed correctly
docstr_tok: ["Test","that","the","gradient","is","computed","correctly"]
code: def test_autograd_gradient(self, n, seed):
      """Test that the gradient is computed correctly"""
      time = qnp.array(1.5)
      coeffs = qnp.array([1.23, -0.45], requires_grad=False)
      terms = [qml.PauliX(0), qml.PauliZ(0)]
  
      dev = qml.device("default.qubit", wires=1)
  
      @qml.qnode(dev)
      def circ(time, coeffs):
          h = qml.dot(coeffs, terms)
          qml.QDrift(h, time, n=n, seed=seed)
          return qml.expval(qml.Hadamard(0))
  
      @qml.qnode(dev)
      def reference_circ(time, coeffs):
          with qml.QueuingManager.stop_recording():
              decomp = _sample_decomposition(
                  coeffs, terms, time, n, seed
              )
  
          for op in decomp:
              qml.apply(op)
  
          return qml.expval(qml.Hadamard(0))
  
      measured_grad = qml.grad(circ)(time, coeffs)
      reference_grad = qml.grad(reference_circ)(time, coeffs)
      assert allclose(measured_grad, reference_grad)
  
imports: import copy
  from functools import reduce
  import pytest
  import pennylane
  from pennylane import numpy
  from pennylane.math import allclose, isclose
  from pennylane.templates.subroutines.qdrift import _sample_decomposition
label_desc: Use image node_id 11 for calling the TestIntegration obj's underlying member method code with example usage: obj.test_autograd_gradient(n, seed) and returns: qml, qml