import torch


def one_hot_encoding(input):
    """
    One-hot encoder
    
    Inputs:
        - input : 1D tensor containing labels (N,)
    Outputs:
        - output: one-hot encoded tensor (N, C)
        - classes: all unique class in order (C,)
    """
    if len(input.shape)>1 and input.shape[1]>1:
        raise ValueError("Tensor to be encoded, should have only one dimension or the second dimension should have size of one!")
    classes = input.unique()
    N = input.shape[0]
    C = classes.shape[0]
    output = torch.zeros(N,C).long()
    output[torch.arange(N), input] = 1
    return output, classes