class_docstr: Tests for adjoint_jacobian
class_docstr_tok: ["Tests","for","adjoint_jacobian"]
docstr: Tests that the gradients of circuits match between the finite difference and device
  methods.
code: def test_gradients(self, op, obs, tol):
      """Tests that the gradients of circuits match between the finite difference and device
      methods."""
  
      ops = [
          qml.Hadamard(wires=0),
          qml.RX(0.543, wires=0),
          qml.CNOT(wires=[0, 1]),
          op,
          qml.Rot(1.3, -2.3, 0.5, wires=[0]),
          qml.RZ(-0.5, wires=0),
          qml.adjoint(qml.RY(0.5, wires=1)),
          qml.CNOT(wires=[0, 1]),
      ]
      measurements = [
          qml.expval(obs(wires=0)),
          qml.expval(qml.PauliZ(wires=1)),
      ]
  
      qs = QuantumScript(
          ops,
          measurements,
          trainable_params=list(range(1, 1 + op.num_params)),
      )
  
      qs_valid, _ = qml.devices.preprocess.decompose(qs, adjoint_ops)
      qs_valid = qs_valid[0]
  
      qs_valid.trainable_params = set(range(1, 1 + op.num_params))
  
      tapes, fn = qml.gradients.finite_diff(qs)
      results = tuple(qml.devices.qubit.simulate(t) for t in tapes)
      numeric_val = fn(results)
      grad_D = adjoint_jacobian(qs_valid)
  
      grad_F = np.squeeze(numeric_val)
  
      assert np.allclose(grad_D, grad_F, atol=tol, rtol=0)
      assert isinstance(grad_D, tuple)
  
imports: import pytest
  import pennylane
  from pennylane.devices.qubit import adjoint_jacobian, adjoint_jvp, adjoint_vjp
  from pennylane.tape import QuantumScript
  import pennylane.numpy
label_desc: Use image node_id 4 for calling the TestAdjointJacobian obj's underlying member method code with example usage: obj.test_gradients(op, obs, tol) without return types