code: def ref_unique(
      x, flatten, axis, sorted, with_index, with_inverse, with_counts
  ):
      if flatten:
          axis = None
      y, indices, inverse_indices, counts = np.unique(
          x, True, True, True, axis
      )
  
      if not sorted:
          argsort_indices = np.argsort(indices)
          inverse_arg = {
              arg_val: arg_index
              for arg_index, arg_val in enumerate(argsort_indices)
          }
          indices = indices[argsort_indices]
          counts = counts[argsort_indices]
          y = np.take(x, indices, axis=axis)
          inverse_indices = np.asarray(
              [inverse_arg[i] for i in inverse_indices]
          )
  
      outputs = (y,)
      indices = indices.astype(np.int64)
      inverse_indices = inverse_indices.astype(np.int64)
      counts = counts.astype(np.int64)
      if with_index:
          outputs += (indices,)
      if with_inverse:
          outputs += (inverse_indices,)
      if with_counts:
          outputs += (counts,)
      return outputs
  
file_path: nnabla/python/test/function/test_unique.py
imports: import pytest
  import numpy
  import nnabla
  import nnabla.functions
  from nbla_test_utils import list_context
  from nnabla.testing import assert_allclose
label_desc: Use image node_id 2 for calling a global function with example usage: ref_unique(x, flatten, axis, sorted, with_index, with_inverse, with_counts) and returns: outputs