code: def _single_tensor_radam(
      params: List[Tensor],
      grads: List[Tensor],
      exp_avgs: List[Tensor],
      exp_avg_sqs: List[Tensor],
      state_steps: List[Tensor],
      *,
      beta1: float,
      beta2: float,
      lr: float,
      weight_decay: float,
      eps: float,
      differentiable: bool,
      decoupled_weight_decay: bool,
      has_complex: bool,
  ):
      for i, param in enumerate(params):
          grad = grads[i]
          exp_avg = exp_avgs[i]
          exp_avg_sq = exp_avg_sqs[i]
          step_t = state_steps[i]
  
          if torch.is_complex(param):
              param = torch.view_as_real(param)
              grad = torch.view_as_real(grad)
              exp_avg = torch.view_as_real(exp_avg)
              exp_avg_sq = torch.view_as_real(exp_avg_sq)
  
          # update step
          step_t += 1
          step = _get_value(step_t)
  
          bias_correction1 = 1 - beta1**step
          bias_correction2 = 1 - beta2**step
  
          if weight_decay != 0:
              if decoupled_weight_decay:
                  param.mul_(1 - lr * weight_decay)
              else:
                  grad = grad.add(param, alpha=weight_decay)
  
          # Decay the first and second moment running average coefficient
          exp_avg.lerp_(grad, 1 - beta1)
          exp_avg_sq.mul_(beta2).addcmul_(grad, grad, value=1 - beta2)
  
          # correcting bias for the first moving moment
          bias_corrected_exp_avg = exp_avg / bias_correction1
  
          # maximum length of the approximated SMA
          rho_inf = 2 / (1 - beta2) - 1
          # compute the length of the approximated SMA
          rho_t = (
              rho_inf - 2 * step * (beta2**step) / bias_correction2
          )
  
          if rho_t > 5.0:
              # Compute the variance rectification term and update parameters accordingly
              rect = math.sqrt(
                  (rho_t - 4)
                  * (rho_t - 2)
                  * rho_inf
                  / ((rho_inf - 4) * (rho_inf - 2) * rho_t)
              )
              exp_avg_sq_sqrt = exp_avg_sq.sqrt()
              if differentiable:
                  exp_avg_sq_sqrt = exp_avg_sq_sqrt.add(eps)
              else:
                  exp_avg_sq_sqrt = exp_avg_sq_sqrt.add_(eps)
              adaptive_lr = (
                  math.sqrt(bias_correction2) / exp_avg_sq_sqrt
              )
              param.add_(
                  bias_corrected_exp_avg * lr * adaptive_lr * rect,
                  alpha=-1.0,
              )
          else:
              param.add_(bias_corrected_exp_avg * lr, alpha=-1.0)
  
file_path: pytorch/torch/optim/radam.py
imports: import math
  from typing import List, Optional
  import torch
  from torch import Tensor
  from .optimizer import Optimizer, _default_to_fused_or_foreach, _differentiable_doc, _dispatch_sqrt, _foreach_doc, _get_scalar_dtype, _get_value, _stack_if_compiling, _use_grad_for_differentiable, _view_as_real
label_desc: Use image node_id 2 for calling a global function with example usage: _single_tensor_radam(params, grads, exp_avgs, exp_avg_sqs, state_steps) without return types