code: def invert_permutation(
      x: Union[torch.Tensor, list, tuple],
      /,
  ) -> torch.Tensor:
      x = torch.tensor(x) if not ivy.is_array(x) else x
      sorted_indices = torch.argsort(x)
      inverse = torch.zeros_like(sorted_indices)
      inverse[sorted_indices] = torch.arange(len(x))
      inverse_permutation = torch.argsort(inverse)
      return inverse_permutation
  
imports: import torch
  from typing import Optional, Union
  import ivy
label_desc: Use image node_id 1 for calling a global function with example usage: invert_permutation() and returns: inverse_permutation