class_docstr: Unit tests for the hadamard_grad function
class_docstr_tok: ["Unit","tests","for","the","hadamard_grad","function"]
docstr: Tests that the automatic gradient of an arbitrary Euler-angle-parameterized gate is correct.
code: def test_rot_gradient(self, theta, tol):
      """Tests that the automatic gradient of an arbitrary Euler-angle-parameterized gate is correct."""
      dev = qml.device("default.qubit", wires=2)
      params = np.array([theta, theta**3, np.sqrt(2) * theta])
  
      with qml.queuing.AnnotatedQueue() as q:
          qml.StatePrep(
              np.array([1.0, -1.0], requires_grad=False) / np.sqrt(2),
              wires=0,
          )
          qml.Rot(*params, wires=[0])
          qml.expval(qml.PauliZ(0))
  
      tape = qml.tape.QuantumScript.from_queue(q)
      tape.trainable_params = {1, 2, 3}
  
      num_params = len(tape.trainable_params)
      res_hadamard, tapes = grad_fn(tape, dev)
  
      assert len(tapes) == num_params
      assert isinstance(res_hadamard, tuple)
      assert len(res_hadamard) == num_params
  
      res_param_shift, _ = grad_fn(tape, dev, qml.gradients.param_shift)
  
      assert np.allclose(
          res_hadamard, res_param_shift, atol=tol, rtol=0
      )
  
imports: import pytest
  import pennylane
  from pennylane import numpy
label_desc: Use image node_id 4 for calling the TestHadamardGrad obj's underlying member method code with example usage: obj.test_rot_gradient(theta, tol) without return types