class_docstr: Adam optimizer for fairseq.
  
  Important note: this optimizer corresponds to the "AdamW" variant of
  Adam in its weight decay behavior. As such, it is most closely
  analogous to torch.optim.AdamW from PyTorch.
class_docstr_tok: ["Adam","optimizer","for","fairseq",".","Important","note",":","this","optimizer","corresponds","to","the","``","AdamW","''","variant","of","Adam","in","its","weight","decay","behavior",".","As","such",",","it","is","most","closely","analogous","to","torch.optim.AdamW","from","PyTorch","."]
code: def __init__(self, args, params):
      super().__init__(args)
      fused_adam_cls = LSAdam
      use_fused_adam = (
          not getattr(args, "use_old_adam", False)
          and fused_adam_cls is not None
          and torch.cuda.is_available()
      )
      if getattr(args, "tpu", False):
          # on TPUs we use the Adam defined here, since it
          # automatically casts gradients to FP32
          self._optimizer = Adam(params, **self.optimizer_config)
      elif use_fused_adam:
          logger.info("using LightSeq Adam")
          self._optimizer = fused_adam_cls(
              params, **self.optimizer_config
          )
      else:
          self._optimizer = Adam(params, **self.optimizer_config)
  
imports: import logging
  import math
  from dataclasses import dataclass, field
  from typing import List
  import torch
  import torch.distributed
  import torch.optim
  from fairseq.dataclass import FairseqDataclass
  from fairseq.optim import FairseqOptimizer, register_optimizer
  from omegaconf import II
  from lightseq.training.ops.pytorch.adam import LSAdam
label_desc: Use image node_id 1 to create a new LSFSAdam object from inherited base classes: FairseqOptimizer with example: obj = LSFSAdam(args, params)