code: def _unique1d(
      ar,
      return_index=False,
      return_inverse=False,
      return_counts=False,
      *,
      equal_nan=True,
      inverse_shape=None,
  ):
      """
      Find the unique elements of an array, ignoring shape.
      """
      ar = np.asanyarray(ar).flatten()
  
      optional_indices = return_index or return_inverse
  
      if optional_indices:
          perm = ar.argsort(
              kind="mergesort" if return_index else "quicksort"
          )
          aux = ar[perm]
      else:
          ar.sort()
          aux = ar
      mask = np.empty(aux.shape, dtype=np.bool)
      mask[:1] = True
      if (
          equal_nan
          and aux.shape[0] > 0
          and aux.dtype.kind in "cfmM"
          and np.isnan(aux[-1])
      ):
          if (
              aux.dtype.kind == "c"
          ):  # for complex all NaNs are considered equivalent
              aux_firstnan = np.searchsorted(
                  np.isnan(aux), True, side="left"
              )
          else:
              aux_firstnan = np.searchsorted(aux, aux[-1], side="left")
          if aux_firstnan > 0:
              mask[1:aux_firstnan] = (
                  aux[1:aux_firstnan] != aux[: aux_firstnan - 1]
              )
          mask[aux_firstnan] = True
          mask[aux_firstnan + 1 :] = False
      else:
          mask[1:] = aux[1:] != aux[:-1]
  
      ret = (aux[mask],)
      if return_index:
          ret += (perm[mask],)
      if return_inverse:
          imask = np.cumsum(mask) - 1
          inv_idx = np.empty(mask.shape, dtype=np.intp)
          inv_idx[perm] = imask
          ret += (inv_idx.reshape(inverse_shape),)
      if return_counts:
          idx = np.concatenate(np.nonzero(mask) + ([mask.size],))
          ret += (np.diff(idx),)
      return ret
  
imports: import functools
  import warnings
  from typing import NamedTuple
  import numpy
  from numpy._core import overrides
label_desc: Use image node_id 6 for calling a global function with example usage: _unique1d(ar, return_index, return_inverse, return_counts) and returns: ret