def parse_labels_mapping(s):
    """
    Parse the mapping between a label type and it's feature map.
    For instance:
    '0;1;2;3' -> [0, 1, 2, 3]
    '0+2;3'   -> [0, None, 0, 1]
    '3;0+2;1' -> [1, 2, 1, 0]
    """
    if len(s) > 0:
        split = [[int(y) for y in x.split('+')] for x in s.split(';')]
        elements = sum(split, [])
        assert all(x in range(4) for x in elements)
        assert len(elements) == len(set(elements))
        labels_mapping = []
        for i in range(4):
            found = False
            for j, l in enumerate(split):
                if i in l:
                    assert not found
                    found = True
                    labels_mapping.append(j)
            if not found:
                labels_mapping.append(None)
        assert len(labels_mapping) == 4
    else:
        labels_mapping = None
    return labels_mapping