class_docstr: Basic gradient-descent optimizer.
  
  Base class for other gradient-descent-based optimizers.
  
  A step of the gradient descent optimizer computes the new values via the rule
  
  .. math::
  
      x^{(t+1)} = x^{(t)} - \eta \nabla f(x^{(t)}).
  
  where :math:`\eta` is a user-defined hyperparameter corresponding to step size.
  
  Args:
      stepsize (float): the user-defined hyperparameter :math:`\eta`
  
  .. note::
  
      When using ``torch``, ``tensorflow`` or ``jax`` interfaces, refer to :doc:`Gradients and training </introduction/interfaces>` for suitable optimizers.
docstr: Compute gradient of the objective function at the given point and return it along with
  the objective function forward pass (if available).
  
  Args:
      objective_fn (function): the objective function for optimization
      args (tuple): tuple of NumPy arrays containing the current parameters for the
          objection function
      kwargs (dict): keyword arguments for the objective function
      grad_fn (function): optional gradient function of the objective function with respect to
          the variables ``args``. If ``None``, the gradient function is computed automatically.
          Must return the same shape of tuple [array] as the autograd derivative.
  
  Returns:
      tuple (array): NumPy array containing the gradient :math:`\nabla f(x^{(t)})` and the
      objective function output. If ``grad_fn`` is provided, the objective function
      will not be evaluted and instead ``None`` will be returned.
docstr_tok: ["Compute","gradient","of","the","objective","function","at","the","given","point","and","return","it","along","with","the","objective","function","forward","pass","(","if","available",")",".","Args",":","objective_fn","(","function",")",":","the","objective","function","for","optimization","args","(","tuple",")",":","tuple","of","NumPy","arrays","containing","the","current","parameters","for","the","objection","function","kwargs","(","dict",")",":","keyword","arguments","for","the","objective","function","grad_fn","(","function",")",":","optional","gradient","function","of","the","objective","function","with","respect","to","the","variables","``","args","``",".","If","``","None","``",",","the","gradient","function","is","computed","automatically",".","Must","return","the","same","shape","of","tuple","[","array","]","as","the","autograd","derivative",".","Returns",":","tuple","(","array",")",":","NumPy","array","containing","the","gradient",":","math",":","`","\\nabla","f","(","x^","{","(","t",")","}",")","`","and","the","objective","function","output",".","If","``","grad_fn","``","is","provided",",","the","objective","function","will","not","be","evaluted","and","instead","``","None","``","will","be","returned","."]
code: def compute_grad(objective_fn, args, kwargs, grad_fn=None):
      r"""Compute gradient of the objective function at the given point and return it along with
      the objective function forward pass (if available).
  
      Args:
          objective_fn (function): the objective function for optimization
          args (tuple): tuple of NumPy arrays containing the current parameters for the
              objection function
          kwargs (dict): keyword arguments for the objective function
          grad_fn (function): optional gradient function of the objective function with respect to
              the variables ``args``. If ``None``, the gradient function is computed automatically.
              Must return the same shape of tuple [array] as the autograd derivative.
  
      Returns:
          tuple (array): NumPy array containing the gradient :math:`\nabla f(x^{(t)})` and the
          objective function output. If ``grad_fn`` is provided, the objective function
          will not be evaluted and instead ``None`` will be returned.
      """
      g = get_gradient(objective_fn) if grad_fn is None else grad_fn
      grad = g(*args, **kwargs)
      forward = getattr(g, "forward", None)
  
      num_trainable_args = sum(
          getattr(arg, "requires_grad", False) for arg in args
      )
      grad = (grad,) if num_trainable_args == 1 else grad
  
      return grad, forward
  
imports: from pennylane._grad import grad
label_desc: Use image node_id 4 for calling the GradientDescentOptimizer obj's underlying member method code with example usage: obj.compute_grad(objective_fn, args, kwargs, grad_fn) and returns: grad,  forward