If a label occurs more than once, add num. as suffix.

def unique_labels(line_labels):
    """If a label occurs more than once, add num. as suffix."""
    from collections import defaultdict
    d = defaultdict(int)
    for i in line_labels:
        d[i] += 1
    d = dict((i, k) for i, k in d.items() if k != 1)
    line_labels_u = []
    for lab in reversed(line_labels):
        c = d.get(lab, 0)
        if c >= 1:
            v = lab + "_num_" + str(c)
            d[lab] -= 1
        else:
            v = lab
        line_labels_u.insert(0, v)

    return line_labels_u