code: def _finish(self, update_ops, name_scope):
      
      iter_ = self._get_iter_variable()
      beta1_power, beta2_power = self._get_beta_accumulators()
      with tf.control_dependencies(update_ops):
        with tf.colocate_with(iter_):
  
          def update_beta_op():
            update_beta1 = beta1_power.assign(
                beta1_power * self._beta1_t,
                use_locking=self._use_locking)
            update_beta2 = beta2_power.assign(
                beta2_power * self._beta2_t,
                use_locking=self._use_locking)
            return tf.group(update_beta1, update_beta2)
          maybe_update_beta = tf.cond(
              tf.equal(iter_, 0), update_beta_op, tf.no_op)
          with tf.control_dependencies([maybe_update_beta]):
            update_iter = iter_.assign(tf.mod(iter_ + 1, self._n_t),
                                       use_locking=self._use_locking)
      return tf.group(
          *update_ops + [update_iter, maybe_update_beta], name=name_scope)
docs: Updates beta_power variables every n batches and incrs counter.