def reference_alias(metric, reference):
    """
    Format a metric key for a reference.

    :return:
        A string that is used as the key for a reference metric.
    """
    key = metric.alias
    if reference is None:
        return key
    return '{}_{}'.format(key, reference.alias)
