code: def invert_permutation(
      permutation: Optional[Tensor],
  ) -> Optional[Tensor]:
      if permutation is None:
          return None
      output = torch.empty_like(
          permutation, memory_format=torch.legacy_contiguous_format
      )
      output.scatter_(
          0,
          permutation,
          torch.arange(
              0, permutation.numel(), device=permutation.device
          ),
      )
      return output
  
imports: import warnings
  from typing import Iterable, List, NamedTuple, Tuple, Union
  import torch
  from torch import Tensor
  from ...None import _VF
  from ..._jit_internal import Optional
label_desc: Use image node_id 4 for calling a global function with example usage: invert_permutation(permutation) and returns: output, None