code: def _multi_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,
  ):
      if len(params) == 0:
          return
  
      torch._foreach_mul_(grads, clip_global_grad_norm)
  
      # for memory saving, we use `neg_pre_grads`
      # to get some temp variable in a inplace way
      torch._foreach_add_(neg_pre_grads, grads)
  
      torch._foreach_mul_(exp_avgs, beta1)
      torch._foreach_add_(exp_avgs, grads, alpha=1 - beta1)  # m_t
  
      torch._foreach_mul_(exp_avg_diffs, beta2)
      torch._foreach_add_(
          exp_avg_diffs, neg_pre_grads, alpha=1 - beta2
      )  # diff_t
  
      torch._foreach_mul_(neg_pre_grads, beta2)
      torch._foreach_add_(neg_pre_grads, grads)
      torch._foreach_mul_(exp_avg_sqs, beta3)
      torch._foreach_addcmul_(
          exp_avg_sqs, neg_pre_grads, neg_pre_grads, value=1 - beta3
      )  # n_t
  
      denom = torch._foreach_sqrt(exp_avg_sqs)
      torch._foreach_div_(denom, bias_correction3_sqrt)
      torch._foreach_add_(denom, eps)
  
      step_size_diff = lr * beta2 / bias_correction2
      step_size = lr / bias_correction1
  
      if no_prox:
          torch._foreach_mul_(params, 1 - lr * weight_decay)
          torch._foreach_addcdiv_(
              params, exp_avgs, denom, value=-step_size
          )
          torch._foreach_addcdiv_(
              params, exp_avg_diffs, denom, value=-step_size_diff
          )
      else:
          torch._foreach_addcdiv_(
              params, exp_avgs, denom, value=-step_size
          )
          torch._foreach_addcdiv_(
              params, exp_avg_diffs, denom, value=-step_size_diff
          )
          torch._foreach_div_(params, 1 + lr * weight_decay)
      torch._foreach_zero_(neg_pre_grads)
      torch._foreach_add_(neg_pre_grads, grads, 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 2 for calling a global function with example usage: _multi_tensor_adan(params, grads, exp_avgs, exp_avg_sqs, exp_avg_diffs, neg_pre_grads) without return types