class_docstr: Test the Gradient Descent optimizer
class_docstr_tok: ["Test","the","Gradient","Descent","optimizer"]
docstr: Test that returned cost is correct if gradient function is supplied
docstr_tok: ["Test","that","returned","cost","is","correct","if","gradient","function","is","supplied"]
code: def test_step_and_cost_supplied_grad(self, args, f, df):
      """Test that returned cost is correct if gradient function is supplied"""
      stepsize = 0.1
      sgd_opt = GradientDescentOptimizer(stepsize)
  
      _, res = sgd_opt.step_and_cost(f, args, grad_fn=df)
      expected = f(args)
      assert np.all(res == expected)
  
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 2 for calling the TestGradientDescentOptimizer obj's underlying member method code with example usage: obj.test_step_and_cost_supplied_grad(args, f, df) without return types