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: Update the variables to take a single optimization step. Flattens and unflattens
  the inputs to maintain nested iterables as the parameters of the optimization.
  
  Args:
      grad (tuple [array]): the gradient of the objective
          function at point :math:`x^{(t)}`: :math:`\nabla f(x^{(t)})`
      args (tuple): the current value of the variables :math:`x^{(t)}`
  
  Returns:
      list [array]: the new values :math:`x^{(t+1)}`
docstr_tok: ["Update","the","variables","to","take","a","single","optimization","step",".","Flattens","and","unflattens","the","inputs","to","maintain","nested","iterables","as","the","parameters","of","the","optimization",".","Args",":","grad","(","tuple","[","array","]",")",":","the","gradient","of","the","objective","function","at","point",":","math",":","`","x^","{","(","t",")","}","`",":",":","math",":","`","\\nabla","f","(","x^","{","(","t",")","}",")","`","args","(","tuple",")",":","the","current","value","of","the","variables",":","math",":","`","x^","{","(","t",")","}","`","Returns",":","list","[","array","]",":","the","new","values",":","math",":","`","x^","{","(","t+1",")","}","`"]
code: def apply_grad(self, grad, args):
      r"""Update the variables to take a single optimization step. Flattens and unflattens
      the inputs to maintain nested iterables as the parameters of the optimization.
  
      Args:
          grad (tuple [array]): the gradient of the objective
              function at point :math:`x^{(t)}`: :math:`\nabla f(x^{(t)})`
          args (tuple): the current value of the variables :math:`x^{(t)}`
  
      Returns:
          list [array]: the new values :math:`x^{(t+1)}`
      """
      args_new = list(args)
  
      trained_index = 0
      for index, arg in enumerate(args):
          if getattr(arg, "requires_grad", False):
              args_new[index] = (
                  arg - self.stepsize * grad[trained_index]
              )
  
              trained_index += 1
  
      return args_new
  
imports: from pennylane._grad import grad
label_desc: Use image node_id 5 for calling the GradientDescentOptimizer obj's underlying member method code with example usage: obj.apply_grad(grad, args) and returns: args_new