Solved by ptrblck in post #3 
              
              
                This should work, if I understand the use case correctly: 
lengths = torch.tensor([2, 3, 4, 5])
scores = torch.arange(1, lengths.sum()+1).float()

idx = torch.repeat_interleave(torch.arange(len(lengths)), lengths)

out = torch.zeros(len(lengths), len(scores))
out.scatter_(0, idx.unsqueeze(0), scores…