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 circuit executes as expected using autograd
docstr_tok: ["Test","that","the","circuit","executes","as","expected","using","autograd"]
code: def test_execution_autograd(self, coeffs, ops, seed):
      """Test that the circuit executes as expected using autograd"""
  
      time = qnp.array(0.5)
      coeffs = qnp.array(coeffs, requires_grad=False)
  
      dev = qml.device("default.qubit", wires=[0, 1])
  
      @qml.qnode(dev)
      def circ(time):
          hamiltonian = qml.dot(coeffs, ops)
          qml.QDrift(hamiltonian, time, n=2, seed=seed)
          return qml.state()
  
      expected_decomp = _sample_decomposition(
          coeffs, ops, time, n=2, seed=seed
      )
  
      initial_state = qnp.array([1.0, 0.0, 0.0, 0.0])
  
      expected_state = (
          reduce(
              lambda x, y: x @ y,
              [
                  qml.matrix(op, wire_order=[0, 1])
                  for op in expected_decomp
              ],
          )
          @ initial_state
      )
      state = circ(time)
  
      assert allclose(expected_state, state)
  
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 2 for calling the TestIntegration obj's underlying member method code with example usage: obj.test_execution_autograd(coeffs, ops, seed) and returns: qml