import torch


def convert_y_to_one_hot(y, nc):
    """Converts a tensor of labels to a one_hot encoded version"""
    new_y = torch.zeros([len(y), nc], dtype=torch.uint8, device='cpu')
    y = y.view(-1, 1)
    new_y.scatter_(1, y, 1)
    return new_y