code: def add_single_gpu_param_update_ops(model, gpu_id):
      # Learning rate of 0 is a dummy value to be set properly at the
      # start of training
      lr = model.param_init_net.ConstantFill(
          [], "lr", shape=[1], value=0.0
      )
      one = model.param_init_net.ConstantFill(
          [], "one", shape=[1], value=1.0
      )
      wd = model.param_init_net.ConstantFill(
          [], "wd", shape=[1], value=cfg.SOLVER.WEIGHT_DECAY
      )
      # weight decay of GroupNorm's parameters
      wd_gn = model.param_init_net.ConstantFill(
          [], "wd_gn", shape=[1], value=cfg.SOLVER.WEIGHT_DECAY_GN
      )
      for param in model.TrainableParams(gpu_id=gpu_id):
          logger.debug("param " + str(param) + " will be updated")
          param_grad = model.param_to_grad[param]
          # Initialize momentum vector
          param_momentum = model.param_init_net.ConstantFill(
              [param], param + "_momentum", value=0.0
          )
          if param in model.biases:
              # Special treatment for biases (mainly to match historical impl.
              # details):
              # (1) Do not apply weight decay
              # (2) Use a 2x higher learning rate
              model.Scale(param_grad, param_grad, scale=2.0)
          elif param in model.gn_params:
              # Special treatment for GroupNorm's parameters
              model.WeightedSum(
                  [param_grad, one, param, wd_gn], param_grad
              )
          elif cfg.SOLVER.WEIGHT_DECAY > 0:
              # Apply weight decay to non-bias weights
              model.WeightedSum(
                  [param_grad, one, param, wd], param_grad
              )
          # Update param_grad and param_momentum in place
          model.net.MomentumSGDUpdate(
              [param_grad, param_momentum, lr, param],
              [param_grad, param_momentum, param],
              momentum=cfg.SOLVER.MOMENTUM,
          )
  
file_path: dense-pose/detectron/modeling/optimizer.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  import logging
  from caffe2.python import muji
  from detectron.core.config import cfg
  import detectron.utils.c2
label_desc: Use image node_id 4 for calling a global function with example usage: add_single_gpu_param_update_ops(model, gpu_id) without return types