Solved by ptrblck in post #5 
              
              
                Ah OK, so idx would be used in dim0: 
M, D, K = 5, 4, 2
x = torch.randn(M, D)
print(x)
> tensor([[ 0.3545, -1.2674, -0.1321, -0.4732],
          [-0.9573,  0.8507, -0.1691,  0.6376],
          [ 0.1386, -1.4488,  0.5860, -0.0135],
          [-0.9486, -0.2253, -1.0952, -0.0432],
          [-0.0213,  …