code: def apply_momentum(r, t, x, g, v, norm_coefficient, alpha, beta):  # type: ignore
      # Add gradient of regularization term.
      g_regularized = norm_coefficient * x + g
      # Coefficient of gradient should be 1 at the first iteration.
      beta_adjusted = beta if t > 0 else 1
      # Update momentum.
      v_new = alpha * v + beta_adjusted * g_regularized
      # Apply SG with momentum update rule.
      x_new = x - r * v_new
      return x_new, v_new
  
file_path: onnx/onnx/backend/test/case/node/momentum.py
imports: import numpy
  import onnx
  from onnx.backend.test.case.base import Base
  from onnx.backend.test.case.node import expect
  from onnx.defs import AI_ONNX_PREVIEW_TRAINING_DOMAIN
label_desc: Use image node_id 1 for calling a global function with example usage: apply_momentum(r, t, x, g, v, norm_coefficient, alpha, beta) and returns: x_new,  v_new