class_docstr: Optimizer that implements the Layer-wise Adaptive Moments (LAMB).
  
  See paper [Large Batch Optimization for Deep Learning: Training BERT
  in 76 minutes](https://arxiv.org/abs/1904.00962).
class_docstr_tok: ["Optimizer","that","implements","the","Layer-wise","Adaptive","Moments","(","LAMB",")",".","See","paper","[","Large","Batch","Optimization","for","Deep","Learning",":","Training","BERT","in","76","minutes","]","(","https",":","\/\/arxiv.org\/abs\/1904.00962",")","."]
code: def _resource_apply_dense(self, grad, var, apply_state=None):
      var_device, var_dtype = var.device, var.dtype.base_dtype
      coefficients = (apply_state or {}).get(
          (var_device, var_dtype)
      ) or self._fallback_apply_state(var_device, var_dtype)
  
      # m_t = beta1 * m + (1 - beta1) * g_t
      m = self.get_slot(var, "m")
      m_scaled_g_values = grad * coefficients["one_minus_beta_1_t"]
      m_t = m * coefficients["beta_1_t"] + m_scaled_g_values
      m_t = m.assign(m_t, use_locking=self._use_locking)
      # v_t = beta2 * v + (1 - beta2) * (g_t * g_t)
      v = self.get_slot(var, "v")
      v_scaled_g_values = (grad * grad) * coefficients[
          "one_minus_beta_2_t"
      ]
      v_t = v * coefficients["beta_2_t"] + v_scaled_g_values
      v_t = v.assign(v_t, use_locking=self._use_locking)
  
      m_t_hat = m_t / (1.0 - coefficients["beta_1_power"])
      v_t_hat = v_t / (1.0 - coefficients["beta_2_power"])
  
      v_sqrt = tf.sqrt(v_t_hat)
      update = m_t_hat / (v_sqrt + coefficients["epsilon"])
  
      if self._do_use_weight_decay(var):
          update += coefficients["weight_decay"] * var
  
      ratio = 1.0
      if self._do_layer_adaptation(var):
          w_norm = tf.norm(var, ord=2)
          g_norm = tf.norm(update, ord=2)
          ratio = tf.where(
              tf.greater(w_norm, 0),
              tf.where(tf.greater(g_norm, 0), (w_norm / g_norm), 1.0),
              1.0,
          )
  
      var_update = var - ratio * coefficients["lr_t"] * update
      return var.assign(var_update, use_locking=self._use_locking)
  
file_path: addons/tensorflow_addons/optimizers/lamb.py
imports: import warnings
  from typing import Optional, Union, Callable, List
  from typeguard import typechecked
  import tensorflow
  from tensorflow_addons.optimizers import KerasLegacyOptimizer
  from tensorflow_addons.utils.types import FloatTensorLike
  from tensorflow_addons.optimizers.utils import is_variable_matched_by_regexes
label_desc: Use image node_id 4 for calling the LAMB obj's underlying member method code with example usage: obj._resource_apply_dense(grad, var, apply_state) and returns: var