code: def test_get_unique_invidx_with_numpy(
      num_nodes, num_edges, nid_begin, nid_end
  ):
      # prepare data for the function
      # generate synthetic edges
      if num_edges > 0:
          srcids = np.random.randint(
              0, num_nodes, (num_edges,)
          )  # exclusive
          dstids = np.random.randint(
              nid_begin, nid_end, (num_edges,)
          )  # exclusive
      else:
          srcids = np.array([])
          dstids = np.array([])
  
      assert nid_begin <= nid_end
  
      # generate unique node-ids for any
      # partition. This list should be sorted.
      # This is equivilant to shuffle_nids in a partition
      unique_nids = np.arange(nid_begin, nid_end)  # exclusive
  
      # test with numpy unique here
      orig_srcids = srcids.copy()
      orig_dstids = dstids.copy()
      input_arr = np.concatenate([srcids, dstids, unique_nids])
  
      # test
      uniques, idxes, srcids, dstids = _get_unique_invidx(
          srcids, dstids, unique_nids
      )
  
      assert len(uniques) == len(idxes)
      assert np.all(srcids < len(uniques))
      assert np.all(dstids < len(uniques))
      assert np.all(uniques[srcids].sort() == orig_srcids.sort())
      assert np.all(uniques[dstids] == orig_dstids)
  
      assert np.all(uniques == input_arr[idxes])
  
      # numpy
      np_uniques, np_idxes, np_inv_idxes = np.unique(
          np.concatenate([orig_srcids, orig_dstids, unique_nids]),
          return_index=True,
          return_inverse=True,
      )
  
      # test uniques
      assert np.all(np_uniques == uniques)
  
      # test idxes array
      assert np.all(
          input_arr[idxes].sort() == input_arr[np_idxes].sort()
      )
  
      # test srcids, inv_indices
      assert np.all(
          uniques[srcids].sort()
          == np_uniques[np_inv_idxes[0 : len(srcids)]].sort()
      )
  
      # test dstids, inv_indices
      assert np.all(
          uniques[dstids].sort()
          == np_uniques[np_inv_idxes[len(srcids) :]].sort()
      )
  
file_path: dgl/tests/tools/test_convert_partition.py
imports: import os
  import tempfile
  import numpy
  import pytest
  import utils
  from convert_partition import _get_unique_invidx
label_desc: Use image node_id 1 for calling a global function with example usage: test_get_unique_invidx_with_numpy(num_nodes, num_edges, nid_begin, nid_end) without return types