Hello, everyone!
Is it possible to implement following function in vectorized fashion, without for cycles, using advanced indexing?
def dumb_foo(x, permutation):
    assert x.ndimension() == permutation.ndimension()
    ret = torch.zeros_like(x)
    if x.ndimension() == 1:
        ret = x[permutation]
    elif x.ndimension() == 2:
        for i in range(x.size(0)):
            ret[i] = x[permutation[i]]
    elif x.ndimension() == 3:
        for i in range(x.size(0)):
            for j in range(x.size(1)):
                ret[i, j] = x[i, j, permutation[i, j]]
    else:
        ValueError("Only 3 dimensions maximum")
    return ret