def one_hot(elements, classes):
    """
    This function transform a list of labels in a matrix where each line is a one-hot encoding of
    the corresponding label in the list. If the labels are not in classes, the corresponding vector has all the
    values set to 0.
    :param elements: list of labels to transform in one-hot encoding.
    :param classes: list of labels.
    :return: a matrix where each line is a one-hot encoding of the labels in input.
    """
    final = []
    for el in elements:
        if el not in classes:
            print('Error. Class {} not recognized in: {}'.format(el, elements))
        current = [1 if i == el else 0 for i in classes]
        final.append(current)
    return final