shenkev:

K[i, :] == X[i, V[i], :]


Say you have
X = torch.randn(64,20,100)
V = torch.randint(0, 20, (64,), dtype=torch.int64)

then could spell the above out to
i = torch.arange(0,64, dtype=torch.int64)
K = data[i, V]

Best regards
Thomas