code: def unique_inverse(
      x: torch.Tensor,
      /,
      *,
      axis: Optional[int] = None,
  ) -> Tuple[torch.Tensor, torch.Tensor]:
      Results = namedtuple("Results", ["values", "inverse_indices"])
  
      if axis is None:
          x = torch.flatten(x)
          axis = 0
  
      values, inverse_indices = torch.unique(
          x, return_inverse=True, dim=axis
      )
      nan_idx = torch.isnan(x)
      if nan_idx.any():
          inverse_indices[nan_idx] = torch.where(torch.isnan(values))[
              0
          ][0]
      inverse_indices = inverse_indices.reshape(x.shape)
      return Results(values, inverse_indices)
  
file_path: ivy/ivy/functional/backends/torch/set.py
imports: import torch
  from typing import Tuple, Optional
  from collections import namedtuple
  from ivy.func_wrapper import with_unsupported_dtypes
  from .None import backend_version
  import ivy
label_desc: Use image node_id 3 for calling a global function with example usage: unique_inverse() and returns: Results