code: def _unique1d(
      ar, return_index=False, return_inverse=False, return_counts=False
  ):
      """
      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
      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,)
      if return_counts:
          idx = np.concatenate(np.nonzero(mask) + ([mask.size],))
          ret += (np.diff(idx),)
      return ret
  
imports: from __future__ import division, absolute_import, print_function
  import functools
  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