Solved by KFrank in post #2 
              
              
                Hello Trinh! 

There might be a cleaner way, but here’s the best I could do: 
import torch
print (torch.__version__)
pair_index = torch.LongTensor([[0,2],[2,7],[1,3],[0,5]])
cols = torch.LongTensor (range (8)).repeat (4, 1)
beg = pair_index[:,0].unsqueeze (1).repeat (1, 8)
end = pair_index[:,1].unsq…