Hi,
This might be a bit inefficient and might take some time depending on the size of the dataset, but it will get the work done:
>>> previous_label=torch.tensor([0,1,2,3,4])
>>> x=previous_label.size()[0]
>>> new_label=torch.zeros([x,x])
>>> for i,val in enumerate(previous_label):
...     new_label[i,:val+1]=1
... 
>>> new_label
tensor([[1., 0., 0., 0., 0.],
        [1., 1., 0., 0., 0.],
        [1., 1., 1., 0., 0.],
        [1., 1., 1., 1., 0.],
        [1., 1., 1., 1., 1.]])

Let me know if this is what you were looking for