code: def loss_select(loss, opt, to_optim):
      """
      Selection function which returns the respective criterion while appending to list of trainable parameters if required.
  
      Args:
          loss:     str, name of loss function to return.
          opt:      argparse.Namespace, contains all training-specific parameters.
          to_optim: list of trainable parameters. Is extend if loss function contains those as well.
      Returns:
          criterion (torch.nn.Module inherited), to_optim (optionally appended)
      """
      if loss == "smoothap":
          loss_params = {
              "anneal": opt.sigmoid_temperature,
              "batch_size": opt.bs,
              "num_id": int(opt.bs / opt.samples_per_class),
              "feat_dims": opt.embed_dim,
          }
          criterion = SmoothAP(**loss_params)
      else:
          raise Exception("Loss {} not available!".format(loss))
  
      return criterion, to_optim
  
file_path: dgl/examples/pytorch/hilander/PSS/Smooth_AP/src/losses.py
imports: import warnings
  import faiss
  import numpy
  import torch
  from scipy import sparse
label_desc: Use image node_id 1 for calling a global function with example usage: loss_select(loss, opt, to_optim) and returns: criterion,  to_optim