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

    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)
    
examples/pytorch/hilander/PSS/Smooth_AP/src/losses.py