class_docstr: Test that the parameter-shift rule for this template matches that of backprop.
class_docstr_tok: ["Test","that","the","parameter-shift","rule","for","this","template","matches","that","of","backprop","."]
docstr: Test parameter-shift rule gradient.
docstr_tok: ["Test","parameter-shift","rule","gradient","."]
code: def test_ps_rule_gradient(self, tol):
      """Test parameter-shift rule gradient."""
  
      dev = qml.device("default.qubit", wires=4)
  
      backprop_grad = qml.grad(
          qml.QNode(circuit_template, dev, diff_method="backprop")
      )
      ps_rule_grad = qml.grad(
          qml.QNode(
              circuit_template, dev, diff_method="parameter-shift"
          )
      )
  
      weights = qml.numpy.array(
          [0.55, 0.72, 0.6, 0.54, 0.42, 0.65], requires_grad=True
      ).reshape(1, -1)
      res = backprop_grad(weights)
      res2 = ps_rule_grad(weights)
      assert qml.math.allclose(res, res2, atol=tol, rtol=0)
  
imports: import pytest
  import numpy
  import pennylane
label_desc: Use image node_id 1 for calling the TestGradient obj's underlying member method code with example usage: obj.test_ps_rule_gradient(tol) without return types