code: def test_factorize_index_obj(ncats, nelem):
      df = DataFrame()
      np.random.seed(0)
  
      # initialize data frame
      df["cats"] = arr = np.random.randint(2, size=10, dtype=np.int32)
      df = df.set_index("cats")
  
      uvals, labels = df.index.factorize()
      np.testing.assert_array_equal(
          labels.values.get(), sorted(set(arr))
      )
      assert isinstance(uvals, cp.ndarray)
      assert isinstance(labels, Index)
  
      encoder = {labels[idx]: idx for idx in range(len(labels))}
      handcoded = [encoder[v] for v in arr]
      np.testing.assert_array_equal(uvals.get(), handcoded)
  
file_path: cudf/python/cudf/cudf/tests/test_factorize.py
imports: import cupy
  import numpy
  import pandas
  import pytest
  import cudf
  from cudf import DataFrame, Index
  from cudf.testing._utils import assert_eq
label_desc: Use image node_id 2 for calling a global function with example usage: test_factorize_index_obj(ncats, nelem) without return types