code: def test_unique():
      x = unique(np.int64(1))
  
      assert len(x.shape) == 1
      assert np.isnan(x.shape[0])
      assert x.dtype == np.dtype(np.int64)
  
      x = tile(x)
  
      assert len(x.chunks) == 1
      assert len(x.chunks[0].shape) == 1
      assert np.isnan(x.chunks[0].shape[0])
      assert x.chunks[0].dtype == np.dtype(np.int64)
  
      x, indices = unique(0.1, return_index=True)
  
      assert len(x.shape) == 1
      assert np.isnan(x.shape[0])
      assert x.dtype == np.dtype(np.float64)
      assert len(indices.shape) == 1
      assert np.isnan(indices.shape[0])
      assert indices.dtype == np.dtype(np.intp)
  
      x, indices = tile(x, indices)
  
      assert len(x.chunks) == 1
      assert len(x.chunks[0].shape) == 1
      assert np.isnan(x.chunks[0].shape[0])
      assert x.chunks[0].dtype == np.dtype(np.float64)
      assert len(indices.chunks) == 1
      assert len(indices.chunks[0].shape) == 1
      assert np.isnan(indices.chunks[0].shape[0])
      assert indices.chunks[0].dtype == np.dtype(np.intp)
  
      with pytest.raises(np.AxisError):
          unique(0.1, axis=1)
  
      raw = np.random.randint(10, size=(10), dtype=np.int64)
      a = tensor(raw, chunk_size=4)
  
      x = unique(a, aggregate_size=2)
  
      assert len(x.shape) == len(raw.shape)
      assert np.isnan(x.shape[0])
      assert x.dtype == np.dtype(np.int64)
  
      x = tile(x)
  
      assert len(x.chunks) == 2
      assert x.nsplits == ((np.nan, np.nan),)
      for i in range(2):
          assert x.chunks[i].shape == (np.nan,)
          assert x.chunks[i].dtype == raw.dtype
  
      raw = np.random.randint(10, size=(10, 20), dtype=np.int64)
      a = tensor(raw, chunk_size=(4, 6))
  
      x, indices, inverse, counts = unique(
          a,
          axis=1,
          aggregate_size=2,
          return_index=True,
          return_inverse=True,
          return_counts=True,
      )
  
      assert x.shape == (10, np.nan)
      assert x.dtype == np.dtype(np.int64)
      assert indices.shape == (np.nan,)
      assert indices.dtype == np.dtype(np.intp)
      assert inverse.shape == (20,)
      assert inverse.dtype == np.dtype(np.intp)
      assert counts.shape == (np.nan,)
      assert counts.dtype == np.dtype(np.int_)
  
      x, indices, inverse, counts = tile(x, indices, inverse, counts)
  
      assert len(x.chunks) == 2
      assert x.nsplits == ((10,), (np.nan, np.nan))
      for i in range(2):
          assert x.chunks[i].shape == (10, np.nan)
          assert x.chunks[i].dtype == raw.dtype
          assert x.chunks[i].index == (0, i)
  
      assert len(indices.chunks) == 2
      assert indices.nsplits == ((np.nan, np.nan),)
      for i in range(2):
          assert indices.chunks[i].shape == (np.nan,)
          assert indices.chunks[i].dtype == raw.dtype
          assert indices.chunks[i].index == (i,)
  
      assert len(inverse.chunks) == 4
      assert inverse.nsplits == ((6, 6, 6, 2),)
      for i in range(4):
          assert inverse.chunks[i].shape == ((6, 6, 6, 2)[i],)
          assert inverse.chunks[i].dtype == np.dtype(np.int64)
          assert inverse.chunks[i].index == (i,)
  
      assert len(counts.chunks) == 2
      assert counts.nsplits == ((np.nan, np.nan),)
      for i in range(2):
          assert counts.chunks[i].shape == (np.nan,)
          assert counts.chunks[i].dtype == np.dtype(np.int_)
          assert counts.chunks[i].index == (i,)
  
imports: import numpy
  import pytest
  from ....core import tile
  from ....core.operand import OperandStage
  from ...datasource import ones, tensor, arange
  from ..None import transpose, broadcast_to, where, argwhere, array_split, split, squeeze, result_type, repeat, copyto, isin, moveaxis, TensorCopyTo, atleast_1d, atleast_2d, atleast_3d, ravel, searchsorted, unique, sort, partition, topk, to_gpu, to_cpu
label_desc: Use image node_id 21 for calling a global function with example usage: test_unique() without return types