def _make_grid_to_short_label(dataset):
    """
    Returns an array x such that x[a][b] gives label index a's b'th unique
    value. In other words, it maps label grid indices a, b to the
    corresponding label value.
    """
    unique_values = [sorted(list(frozenset(column)))
                     for column
                     in dataset.y[:, :5].transpose()]

    # If dataset contains blank images, removes the '-1' labels
    # corresponding to blank images, since they aren't contained in the
    # label grid.
    category_index = dataset.label_name_to_index['category']
    unique_categories = unique_values[category_index]
    category_to_name = dataset.label_to_value_funcs[category_index]
    if any(category_to_name(category) == 'blank'
           for category in unique_categories):
        for d in range(1, len(unique_values)):
            assert unique_values[d][0] == -1, ("unique_values: %s" %
                                               str(unique_values))
            unique_values[d] = unique_values[d][1:]

    return unique_values