class_docstr: Test the Gradient Descent optimizer
class_docstr_tok: ["Test","the","Gradient","Descent","optimizer"]
docstr: Tests that basic stochastic gradient descent takes gradient-descent steps correctly
  using user-provided gradients.
docstr_tok: ["Tests","that","basic","stochastic","gradient","descent","takes","gradient-descent","steps","correctly","using","user-provided","gradients","."]
code: def test_gradient_descent_optimizer_usergrad(
      self, x_start, f, df, tol
  ):
      """Tests that basic stochastic gradient descent takes gradient-descent steps correctly
      using user-provided gradients."""
      stepsize = 0.1
      sgd_opt = GradientDescentOptimizer(stepsize)
  
      x_new = sgd_opt.step(f, x_start, grad_fn=df)
      x_correct = x_start - df(x_start) * stepsize
      assert np.allclose(x_new, x_correct, 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 8 for calling the TestGradientDescentOptimizer obj's underlying member method code with example usage: obj.test_gradient_descent_optimizer_usergrad(x_start, f, df, tol) without return types