class_docstr: Implements LANS algorithm.
  
  Currently GPU-only.  Requires Apex to be installed via
  ``pip install -v --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./``.
  
  This version of fused LAMB implements 2 fusions.
  
    * Fusion of the Nesterov LAMB update's elementwise operations
    * A multi-tensor apply launch that batches the elementwise updates applied to all the model's parameters into one or a few kernel launches.
  
  :class:`apex.optimizers.FusedLANS`'s usage is identical to any ordinary Pytorch optimizer::
  
      opt = apex.optimizers.FusedLANS(model.parameters(), lr = ....)
      ...
      opt.step()
  
  :class:`apex.optimizers.FusedLANS` may be used with or without Amp.  If you wish to use :class:`FusedLANS` with Amp,
  you may choose any ``opt_level``::
  
      opt = apex.optimizers.FusedLANS(model.parameters(), lr = ....)
      model, opt = amp.initialize(model, opt, opt_level="O0" or "O1 or "O2")
      ...
      opt.step()
  
  In general, ``opt_level="O1"`` is recommended.
  
  Arguments:
      params (iterable): iterable of parameters to optimize or dicts defining
          parameter groups.
      lr (float, optional): learning rate. (default: 1e-3)
      betas (Tuple[float, float], optional): coefficients used for computing
          running averages of gradient and its norm. (default: (0.9, 0.999))
      eps (float, optional): term added to the denominator to improve
          numerical stability. (default: 1e-8)
      weight_decay (float, optional): weight decay (L2 penalty) (default: 0)
      adam_w_mode (boolean, optional): Apply L2 regularization or weight decay
          True for decoupled weight decay(also known as AdamW) (default: True)
      grad_averaging (bool, optional): whether apply (1-beta2) to grad when
          calculating running averages of gradient. (default: True)
      set_grad_none (bool, optional): whether set grad to None when zero_grad()
          method is called. (default: True)
      normalize_grad (bool, optional): whether to normalize per-tensor grad
          (default: True)
  
  .. _Accelerated Large Batch Optimization of BERT Pretraining in 54 minutes:
      https://arxiv.org/abs/2006.13484
code: def __init__(
      self,
      params,
      lr=1e-3,
      bias_correction=True,
      betas=(0.9, 0.999),
      eps=1e-6,
      weight_decay=0.01,
      adam_w_mode=True,
      grad_averaging=True,
      set_grad_none=True,
      normalize_grad=True,
  ):
      defaults = dict(
          lr=lr,
          bias_correction=bias_correction,
          betas=betas,
          eps=eps,
          weight_decay=weight_decay,
          grad_averaging=grad_averaging,
          normalize_grad=normalize_grad,
      )
      super(FusedLANS, self).__init__(params, defaults)
      from codel import fused_optimizers as amp_C
  
      # Skip buffer
      self._dummy_overflow_buf = torch.tensor(
          [0],
          dtype=torch.int,
          device=self.param_groups[0]["params"][0].device,
      )
      self.multi_tensor_lans = amp_C.multi_tensor_lans
  
      self.adam_w_mode = 1 if adam_w_mode else 0
      self.set_grad_none = set_grad_none
  
file_path: gluon-nlp/src/gluonnlp/torch/optimizers/fused_lans.py
imports: import torch
label_desc: Use image node_id 1 to create a new FusedLANS object from inherited base classes: torch.optim with example: obj = FusedLANS(params, lr, bias_correction, betas, eps, weight_decay, adam_w_mode, grad_averaging, set_grad_none, normalize_grad)