code: def get_optimizer(optimizer, module):
      if isinstance(optimizer, (str, dict)):
          kwargs = {}
          if isinstance(optimizer, dict):
              optimizer = dict(optimizer)
              kwargs = optimizer
              optimizer = optimizer.pop("optim")
  
          optimizer = optimizer.lower()
  
          if optimizer == "sgd":
              kwargs.setdefault("lr", 1e-2)
  
          params = (p for p in module.parameters() if p.requires_grad)
          return all_optimizers_dict[optimizer](params, **kwargs)
  
      return optimizer
  
label_desc: Use image node_id 1 for calling a global function with example usage: get_optimizer(optimizer, module) and returns: optimizer, all_optimizers_dict