import torch x = torch.tensor([[10, 11], [12, 13]]) idx = torch.tensor([[0, 1, 0], [1, 1, 0]]) print(x[idx[0], idx[1]])
It outputs tensor([11, 13,
tensor([11, 13,