Direct indexing with broadcasting should work:
x = torch.randint(0, 10, (10, 2, 3, 4)).float()
y = torch.randn(10, 10)

index_array = x.clone().long()
for i in range(0,x.shape[0]):
    x[i] = y[i][index_array[i]]


x2 = y[torch.arange(y.size(0))[:, None, None, None], index_array]
print((x - x2).abs().max())
# > tensor(0.)