class_docstr: Unit tests for the hadamard_grad function
class_docstr_tok: ["Unit","tests","for","the","hadamard_grad","function"]
docstr: Tests that the Hadamard test gradient agrees with the first and second
  order finite differences
code: def test_gradients_agree_finite_differences(self, tol):
      """Tests that the Hadamard test gradient agrees with the first and second
      order finite differences"""
      params = np.array([0.1, -1.6, np.pi / 5])
  
      with qml.queuing.AnnotatedQueue() as q:
          qml.RX(params[0], wires=[0])
          qml.CNOT(wires=[0, 1])
          qml.RY(-1.6, wires=[0])
          qml.RY(params[1], wires=[1])
          qml.CNOT(wires=[1, 0])
          qml.RX(params[2], wires=[0])
          qml.CNOT(wires=[0, 1])
          qml.expval(qml.PauliZ(0))
  
      tape = qml.tape.QuantumScript.from_queue(q)
      tape.trainable_params = {0, 2, 3}
      dev = qml.device("default.qubit", wires=3)
  
      grad_F1, _ = grad_fn(
          tape, dev, fn=qml.gradients.finite_diff, approx_order=1
      )
      grad_F2, _ = grad_fn(
          tape,
          dev,
          fn=qml.gradients.finite_diff,
          approx_order=2,
          strategy="center",
      )
      grad_A, _ = grad_fn(tape, dev)
  
      # gradients computed with different methods must agree
      assert np.allclose(grad_A, grad_F1, atol=tol, rtol=0)
      assert np.allclose(grad_A, grad_F2, atol=tol, rtol=0)
  
imports: import pytest
  import pennylane
  from pennylane import numpy
label_desc: Use image node_id 10 for calling the TestHadamardGrad obj's underlying member method code with example usage: obj.test_gradients_agree_finite_differences(tol) without return types