Solved by ptrblck in post #2 
              
              
                This should work: 
batch = torch.ones(10, 4)
batch = torch.arange(batch.size(0)).view(-1, 1) * batch

If you are dealing with more dimensions, you might need to change the view call.