code: def build_optimizer(
      model: torch.nn.Module, opts, *args, **kwargs
  ) -> BaseOptim:
      """Helper function to build an optimizer
  
      Args:
          model: A model
          opts: command-line arguments
  
      Returns:
          An instance of BaseOptim
      """
      optim_name = getattr(opts, "optim.name")
      weight_decay = getattr(opts, "optim.weight_decay")
      no_decay_bn_filter_bias = getattr(
          opts, "optim.no_decay_bn_filter_bias"
      )
  
      unwrapped_model = unwrap_model_fn(model)
  
      model_params, lr_mult = unwrapped_model.get_trainable_parameters(
          weight_decay=weight_decay,
          no_decay_bn_filter_bias=no_decay_bn_filter_bias,
          *args,
          **kwargs,
      )
  
      # check to ensure that all trainable model parameters are passed to the model
      if not getattr(opts, "optim.bypass_parameters_check", False):
          check_trainable_parameters(
              model=unwrapped_model, model_params=model_params
          )
      else:
          remove_param_name_key(model_params=model_params)
  
      # set the learning rate multiplier for each parameter
      setattr(opts, "optim.lr_multipliers", lr_mult)
  
      return OPTIM_REGISTRY[optim_name](
          opts, model_params, *args, **kwargs
      )
  
file_path: ml-cvnets/optim/__init__.py
imports: import argparse
  from typing import Dict, List
  import torch.nn
  from optim.base_optim import BaseOptim
  from utils import logger
  from utils.common_utils import unwrap_model_fn
  from utils.registry import Registry
label_desc: Use image node_id 3 for calling a global function with example usage: build_optimizer(model, opts) and returns: OPTIM_REGISTRY