class_docstr: Gradient descent (with momentum) optimizer.
  
  Update rule for parameter `w` with gradient `g` when `momentum` is 0:
  
  ```python
  w = w - learning_rate * g
  ```
  
  Update rule when `momentum` is larger than 0:
  
  ```python
  velocity = momentum * velocity - learning_rate * g
  w = w + velocity
  ```
  
  When `nesterov=True`, this rule becomes:
  
  ```python
  velocity = momentum * velocity - learning_rate * g
  w = w + momentum * velocity - learning_rate * g
  ```
  
  Args:
      learning_rate: A float, a
          `keras.optimizers.schedules.LearningRateSchedule` instance, or
          a callable that takes no arguments and returns the actual value to
          use. The learning rate. Defaults to `0.01`.
      momentum: float hyperparameter >= 0 that accelerates gradient descent in
          the relevant direction and dampens oscillations. 0 is vanilla
          gradient descent. Defaults to `0.0`.
      nesterov: boolean. Whether to apply Nesterov momentum.
          Defaults to `False`.
      {{base_optimizer_keyword_args}}
docstr: Update step given gradient and the associated model variable.
docstr_tok: ["Update","step","given","gradient","and","the","associated","model","variable","."]
code: def update_step(self, gradient, variable, learning_rate):
      """Update step given gradient and the associated model variable."""
      learning_rate = ops.cast(learning_rate, variable.dtype)
      gradient = ops.cast(gradient, variable.dtype)
      m = None
      if self.momentum != 0:
          m = self.momentums[self._get_variable_index(variable)]
  
      if m is not None:
          momentum = ops.cast(self.momentum, variable.dtype)
          self.assign(
              m,
              ops.subtract(
                  ops.multiply(m, momentum),
                  ops.multiply(gradient, learning_rate),
              ),
          )
          if self.nesterov:
              self.assign_add(
                  variable,
                  ops.subtract(
                      ops.multiply(m, momentum),
                      ops.multiply(gradient, learning_rate),
                  ),
              )
          else:
              self.assign_add(variable, m)
      else:
          self.assign_sub(
              variable, ops.multiply(gradient, learning_rate)
          )
  
file_path: keras/keras/optimizers/sgd.py
imports: from keras import ops
  from keras.api_export import keras_export
  from keras.optimizers import optimizer
label_desc: Use image node_id 3 for calling the SGD obj's underlying member method code with example usage: obj.update_step(gradient, variable, learning_rate) without return types