def convert_classes_to_indexes(labels, classes):
    """
    Convert a list of labels representing classes to their corresponding indexes.
    More precisely, convert TripletDataset labels to the index of the class in the
    dataset, while keeping the current label for a FolderDataset dataset.

    :param labels: list of labels to convert.
    :param classes: list of all the classes in the dataset.
    """
    if all([l in classes for l in labels]):
        labels = [classes.index(label) for label in labels]
    return labels