class_docstr: Test the Gradient Descent optimizer
class_docstr_tok: ["Test","the","Gradient","Descent","optimizer"]
docstr: Test that a gradient step can be applied correctly to a set of parameters.
docstr_tok: ["Test","that","a","gradient","step","can","be","applied","correctly","to","a","set","of","parameters","."]
code: def test_apply_grad(self, grad, args, tol):
      """
      Test that a gradient step can be applied correctly to a set of parameters.
      """
      stepsize = 0.1
      sgd_opt = GradientDescentOptimizer(stepsize)
      grad, args = np.array(grad), np.array(args, requires_grad=True)
  
      res = sgd_opt.apply_grad(grad, args)
      expected = args - stepsize * grad
      assert np.allclose(res, expected, atol=tol)
  
file_path: pennylane/tests/optimize/test_gradient_descent.py
imports: import pytest
  import pennylane
  from pennylane import numpy
  from pennylane.optimize import GradientDescentOptimizer
label_desc: Use image node_id 1 for calling the TestGradientDescentOptimizer obj's underlying member method code with example usage: obj.test_apply_grad(grad, args, tol) without return types