class_docstr: RMSProp module.
  
  See: http://www.cs.toronto.edu/~tijmen/csc321/slides/lecture_slides_lec6.pdf
  
  Maintain a moving (discounted) average of the square of updates. Divides each
  update by the root of this average.
  
      ms <- decay * ms + (1-decay) * update^2
      mom <- momentum * mom + learning_rate * update / sqrt(ms + epsilon)
      parameter <- parameter - mom
  
  This implementation of `RMSprop` uses plain momentum, not Nesterov momentum.
  
  The centered version additionally maintains a moving average of the
  gradients, and uses that average to estimate the variance:
  
      mg <- decay * mg + (1-decay) * update
      ms <- decay * ms + (1-decay) * update^2
      mom <- momentum * mom + learning_rate * update / sqrt(ms - mg^2 + epsilon)
      parameter <- parameter - mom
  
  Attributes:
    learning_rate: Learning rate.
    decay: Learning rate decay over each update.
    momentum: Momentum scalar.
    epsilon: Small value to avoid zero denominator.
    centered: `True` if centered.
    mom: Accumulated mom for each parameter.
    ms: Accumulated ms for each parameter.
    mg: Accumulated mg for each parameter.
docstr: Applies updates to parameters.
  
  Args:
    updates: A list of updates to apply to parameters. Updates are often
      gradients as returned by `tf.GradientTape.gradient`.
    parameters: A list of parameters.
  
  Raises:
    ValueError: If `updates` and `parameters` are empty, have different
      lengths, or have inconsistent types.
docstr_tok: ["Applies","updates","to","parameters",".","Args",":","updates",":","A","list","of","updates","to","apply","to","parameters",".","Updates","are","often","gradients","as","returned","by","`","tf.GradientTape.gradient","`",".","parameters",":","A","list","of","parameters",".","Raises",":","ValueError",":","If","`","updates","`","and","`","parameters","`","are","empty",",","have","different","lengths",",","or","have","inconsistent","types","."]
code: def apply(
      self,
      updates: Sequence[types.ParameterUpdate],
      parameters: Sequence[tf.Variable],
  ):
      """Applies updates to parameters.
  
      Args:
        updates: A list of updates to apply to parameters. Updates are often
          gradients as returned by `tf.GradientTape.gradient`.
        parameters: A list of parameters.
  
      Raises:
        ValueError: If `updates` and `parameters` are empty, have different
          lengths, or have inconsistent types.
      """
      optimizer_utils.check_distribution_strategy()
      optimizer_utils.check_updates_parameters(updates, parameters)
      self._initialize(parameters)
      for (
          update,
          parameter,
          mom_var,
          ms_var,
          mg_var,
      ) in itertools.zip_longest(
          updates, parameters, self.mom, self.ms, self.mg
      ):
          if update is None:
              continue
  
          optimizer_utils.check_same_dtype(update, parameter)
          learning_rate = tf.cast(self.learning_rate, update.dtype)
          decay = tf.cast(self.decay, update.dtype)
          mu = tf.cast(self.momentum, update.dtype)
          epsilon = tf.cast(self.epsilon, update.dtype)
  
          if isinstance(update, tf.IndexedSlices):
              # Sparse read our state.
              (
                  update,
                  indices,
              ) = optimizer_utils.deduplicate_indexed_slices(update)
              ms = ms_var.sparse_read(indices)
              mg = (
                  mg_var.sparse_read(indices) if self.centered else None
              )
              mom = mom_var.sparse_read(indices)
  
              # Compute and apply a sparse update to our parameter and state.
              mom, ms, mg = rmsprop_update(
                  update, decay, learning_rate, epsilon, mu, mom, ms, mg
              )
              parameter.scatter_sub(tf.IndexedSlices(mom, indices))
              mom_var.scatter_update(tf.IndexedSlices(mom, indices))
              ms_var.scatter_update(tf.IndexedSlices(ms, indices))
              if self.centered:
                  mg_var.scatter_update(tf.IndexedSlices(mg, indices))
  
          else:
              # Compute and apply a dense update to our parameters and state.
              mom, ms, mg = rmsprop_update(
                  update,
                  decay,
                  learning_rate,
                  epsilon,
                  mu,
                  mom_var,
                  ms_var,
                  mg_var,
              )
              parameter.assign_sub(mom)
              mom_var.assign(mom)
              ms_var.assign(ms)
              if self.centered:
                  mg_var.assign(mg)
  
file_path: sonnet/sonnet/src/optimizers/rmsprop.py
imports: import itertools
  from typing import Optional, Sequence, Union
  from sonnet.src import base
  from sonnet.src import once
  from sonnet.src import types
  from sonnet.src import utils
  from sonnet.src.optimizers import optimizer_utils
  import tensorflow
label_desc: Use image node_id 3 for calling the RMSProp obj's underlying member method code with example usage: obj.apply(updates, parameters) without return types