def flip(x, dim):
    indices = ([slice(None)] * x.dim())
    indices[dim] = torch.arange((x.size(dim) - 1), (- 1), (- 1), dtype=torch.long, device=x.device)
    return x[tuple(indices)]
def flip(x, dim):
    indices = ([slice(None)] * x.dim())
    indices[dim] = torch.arange((x.size(dim) - 1), (- 1), (- 1), dtype=torch.long, device=x.device)
    return x[tuple(indices)]