code: def build_pose_optimizer(cfg, model) -> torch.optim.Optimizer:
      """
      Build an optimizer from config.
      """
      norm_module_types = (
          torch.nn.BatchNorm1d,
          torch.nn.BatchNorm2d,
          torch.nn.BatchNorm3d,
          torch.nn.SyncBatchNorm,
          # NaiveSyncBatchNorm inherits from BatchNorm2d
          torch.nn.GroupNorm,
          torch.nn.InstanceNorm1d,
          torch.nn.InstanceNorm2d,
          torch.nn.InstanceNorm3d,
          torch.nn.LayerNorm,
          torch.nn.LocalResponseNorm,
      )
      params: List[Dict[str, Any]] = []
      memo: Set[torch.nn.parameter.Parameter] = set()
      override: Set[torch.nn.parameter.Parameter] = set()
  
      for module in model.modules():
          for key, value in module.named_parameters(recurse=False):
              if not value.requires_grad:
                  continue
              # Avoid duplicating parameters
              if value in memo:
                  continue
              memo.add(value)
              lr = cfg.CONFIG.TRAIN.LR
              weight_decay = cfg.CONFIG.TRAIN.W_DECAY
              if isinstance(module, norm_module_types):
                  weight_decay = cfg.CONFIG.TRAIN.W_DECAY_NORM
              elif key == "bias":
                  lr = cfg.CONFIG.TRAIN.LR
                  weight_decay = cfg.CONFIG.TRAIN.W_DECAY
              if value in override:
                  raise NotImplementedError("KPS_GRAD_MULT not found")
  
              params += [
                  {
                      "params": [value],
                      "lr": lr,
                      "weight_decay": weight_decay,
                  }
              ]
  
      optimizer = torch.optim.SGD(
          params,
          cfg.CONFIG.TRAIN.LR,
          momentum=cfg.CONFIG.TRAIN.MOMENTUM,
      )
      optimizer = maybe_add_gradient_clipping(cfg, optimizer)
      return optimizer
  
file_path: gluon-cv/gluoncv/torch/utils/task_utils/pose.py
imports: import time
  import logging
  import datetime
  import numpy
  import torch
  from ..None import comm
  from ..utils import AverageMeter
  from ..model_utils import save_model
  from ..optimizer import maybe_add_gradient_clipping
  from ..eval_utils.coco_eval import COCOEvaluator
label_desc: Use image node_id 2 for calling a global function with example usage: build_pose_optimizer(cfg, model) and returns: optimizer