code: def create_optimizer_supernet(
      args, model, has_apex, filter_bias_and_bn=True
  ):
      opt_lower = args.opt.lower()
      weight_decay = args.weight_decay
      if "adamw" in opt_lower or "radam" in opt_lower:
          weight_decay /= args.lr
      if weight_decay and filter_bias_and_bn:
          parameters = add_weight_decay_supernet(
              model, args, weight_decay
          )
          weight_decay = 0.0
      else:
          parameters = model.parameters()
  
      if "fused" in opt_lower:
          assert (
              has_apex and torch.cuda.is_available()
          ), "APEX and CUDA required for fused optimizers"
  
      opt_split = opt_lower.split("_")
      opt_lower = opt_split[-1]
      if opt_lower == "sgd" or opt_lower == "nesterov":
          optimizer = optim.SGD(
              parameters,
              momentum=args.momentum,
              weight_decay=weight_decay,
              nesterov=True,
          )
      elif opt_lower == "momentum":
          optimizer = optim.SGD(
              parameters,
              momentum=args.momentum,
              weight_decay=weight_decay,
              nesterov=False,
          )
      elif opt_lower == "adam":
          optimizer = optim.Adam(
              parameters, weight_decay=weight_decay, eps=args.opt_eps
          )
      else:
          assert False and "Invalid optimizer"
          raise ValueError
  
      return optimizer
  
file_path: nni/examples/nas/legacy/cream/lib/utils/util.py
imports: import sys
  import logging
  import torch
  import argparse
  import torch.nn
  from torch import optim
  from thop import profile, clever_format
  from timm.utils import *
  from lib.config import cfg
label_desc: Use image node_id 4 for calling a global function with example usage: create_optimizer_supernet(args, model, has_apex, filter_bias_and_bn) and returns: optimizer