code: def _single_tensor_adan(
      params: List[Tensor],
      grads: List[Tensor],
      exp_avgs: List[Tensor],
      exp_avg_sqs: List[Tensor],
      exp_avg_diffs: List[Tensor],
      neg_pre_grads: List[Tensor],
      *,
      beta1: float,
      beta2: float,
      beta3: float,
      bias_correction1: float,
      bias_correction2: float,
      bias_correction3_sqrt: float,
      lr: float,
      weight_decay: float,
      eps: float,
      no_prox: bool,
      clip_global_grad_norm: Tensor,
  ):
      for i, param in enumerate(params):
          grad = grads[i]
          exp_avg = exp_avgs[i]
          exp_avg_sq = exp_avg_sqs[i]
          exp_avg_diff = exp_avg_diffs[i]
          neg_grad_or_diff = neg_pre_grads[i]
  
          grad.mul_(clip_global_grad_norm)
  
          # for memory saving, we use `neg_grad_or_diff`
          # to get some temp variable in a inplace way
          neg_grad_or_diff.add_(grad)
  
          exp_avg.mul_(beta1).add_(grad, alpha=1 - beta1)  # m_t
          exp_avg_diff.mul_(beta2).add_(
              neg_grad_or_diff, alpha=1 - beta2
          )  # diff_t
  
          neg_grad_or_diff.mul_(beta2).add_(grad)
          exp_avg_sq.mul_(beta3).addcmul_(
              neg_grad_or_diff, neg_grad_or_diff, value=1 - beta3
          )  # n_t
  
          denom = ((exp_avg_sq).sqrt() / bias_correction3_sqrt).add_(
              eps
          )
          step_size_diff = lr * beta2 / bias_correction2
          step_size = lr / bias_correction1
  
          if no_prox:
              param.mul_(1 - lr * weight_decay)
              param.addcdiv_(exp_avg, denom, value=-step_size)
              param.addcdiv_(exp_avg_diff, denom, value=-step_size_diff)
          else:
              param.addcdiv_(exp_avg, denom, value=-step_size)
              param.addcdiv_(exp_avg_diff, denom, value=-step_size_diff)
              param.div_(1 + lr * weight_decay)
  
          neg_grad_or_diff.zero_().add_(grad, alpha=-1.0)
  
file_path: NeMo/nemo/core/optim/adan.py
imports: import math
  from typing import List
  import torch
  from torch import Tensor
  from torch.optim.optimizer import Optimizer
label_desc: Use image node_id 1 for calling a global function with example usage: _single_tensor_adan(params, grads, exp_avgs, exp_avg_sqs, exp_avg_diffs, neg_pre_grads) without return types