import torch


def make_onehot_encoder(label_features):
    """Convert a number to its one-hot representation vector.

    The one-hot representation is also called the 1-of-amount_of_labels.

    Parameters
    ----------
    label_features: int
        Length of vector

    Returns
    -------
    onehot_encode : function
    """

    def onehot_encode(label):
        y = torch.zeros(label_features)
        if label < label_features:
            y[int(label)] = 1
        return y

    return onehot_encode