parameters: (params: List[Tensor],
          d_p_list: List[Tensor],
          momentum_buffer_list: List[Optional[Tensor]],
          *,
          weight_decay: float,
          momentum: float,
          lr: float,
          dampening: float,
          nesterov: bool,
          maximize: bool)
docstring: r"""Functional API that performs SGD algorithm computation.
  
      See :class:`~torch.optim.SGD` for details.
docstring_summary: r"""Functional API that performs SGD algorithm computation.
docstring_tokens: r Functional API that performs SGD algorithm computation .
function: def sgd(params: List[Tensor],
          d_p_list: List[Tensor],
          momentum_buffer_list: List[Optional[Tensor]],
          *,
          weight_decay: float,
          momentum: float,
          lr: float,
          dampening: float,
          nesterov: bool,
          maximize: bool):
      r"""Functional API that performs SGD algorithm computation.
  
      See :class:`~torch.optim.SGD` for details.
      """
  
      for i, param in enumerate(params):
  
          d_p = d_p_list[i]
          if weight_decay != 0:
              d_p = d_p.add(param, alpha=weight_decay)
  
          if momentum != 0:
              buf = momentum_buffer_list[i]
  
              if buf is None:
                  buf = torch.clone(d_p).detach()
                  momentum_buffer_list[i] = buf
              else:
                  buf.mul_(momentum).add_(d_p, alpha=1 - dampening)
  
              if nesterov:
                  d_p = d_p.add(buf, alpha=momentum)
              else:
                  d_p = buf
  
          alpha = lr if maximize else -lr
          param.add_(d_p, alpha=alpha)
function_tokens: def sgd ( params : List [ Tensor ] , d_p_list : List [ Tensor ] , momentum_buffer_list : List [ Optional [ Tensor ] ] , * , weight_decay : float , momentum : float , lr : float , dampening : float , nesterov : bool , maximize : bool ) : for i , param in enumerate ( params ) : d_p = d_p_list [ i ] if weight_decay != 0 : d_p = d_p . add ( param , alpha = weight_decay ) if momentum != 0 : buf = momentum_buffer_list [ i ] if buf is None : buf = torch . clone ( d_p ) . detach ( ) momentum_buffer_list [ i ] = buf else : buf . mul_ ( momentum ) . add_ ( d_p , alpha = 1 - dampening ) if nesterov : d_p = d_p . add ( buf , alpha = momentum ) else : d_p = buf alpha = lr if maximize else - lr param . add_ ( d_p , alpha = alpha )