class_docstr: Adam with SGD updates every n steps with accumulated gradients.
class_docstr_tok: ["Adam","with","SGD","updates","every","n","steps","with","accumulated","gradients","."]
code: def _apply_sparse_shared(self, grad, var, indices, scatter_add):
      beta1_power, beta2_power = self._get_beta_accumulators()
      beta1_power = tf.cast(beta1_power, var.dtype.base_dtype)
      beta2_power = tf.cast(beta2_power, var.dtype.base_dtype)
      lr_t = tf.cast(self._lr_t, var.dtype.base_dtype)
      beta1_t = tf.cast(self._beta1_t, var.dtype.base_dtype)
      beta2_t = tf.cast(self._beta2_t, var.dtype.base_dtype)
      epsilon_t = tf.cast(self._epsilon_t, var.dtype.base_dtype)
      lr = lr_t * tf.sqrt(1 - beta2_power) / (1 - beta1_power)
      # m_t = beta1 * m + (1 - beta1) * g_t
      m = self.get_slot(var, "m")
      m_scaled_g_values = grad * (1 - beta1_t)
      m_t = tf.assign(m, m * beta1_t, use_locking=self._use_locking)
      with tf.control_dependencies([m_t]):
          m_t = scatter_add(m, indices, m_scaled_g_values)
      # v_t = beta2 * v + (1 - beta2) * (g_t * g_t)
      v = self.get_slot(var, "v")
      v_scaled_g_values = (grad * grad) * (1 - beta2_t)
      v_t = tf.assign(v, v * beta2_t, use_locking=self._use_locking)
      with tf.control_dependencies([v_t]):
          v_t = scatter_add(v, indices, v_scaled_g_values)
      v_sqrt = tf.sqrt(v_t)
      var_update = tf.assign_sub(
          var,
          lr * m_t / (v_sqrt + epsilon_t),
          use_locking=self._use_locking,
      )
      return tf.group(*[var_update, m_t, v_t])
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import tensorflow.compat.v1
  from tensorflow.python.ops import resource_variable_ops
  from tensorflow.python.training import training_ops
label_desc: Use image node_id 11 for calling the MultistepAdamOptimizer obj's underlying member method code with example usage: obj._apply_sparse_shared(grad, var, indices, scatter_add) and returns: tf