def _make_label_to_row_indices(labels):
    """
    Returns a map from short labels (the first 5 elements of the label
    vector) to the list of row indices of rows in the dense design matrix
    with that label.

    For Small NORB, all unique short labels have exactly one row index.

    For big NORB, a short label can have 0-N row indices.
    """
    result = {}

    for row_index, label in enumerate(labels):

        short_label = tuple(label[:5])
        if result.get(short_label, None) is None:
            result[short_label] = []

        result[short_label].append(row_index)

    return result