code: def test_categorize_index():
      # Object dtype
      pdf = _compat.makeDataFrame()
      ddf = dd.from_pandas(pdf, npartitions=5)
      result = ddf.compute()
  
      ddf2 = ddf.categorize()
      assert ddf2.index.cat.known
      assert_eq(
          ddf2,
          result.set_index(pd.CategoricalIndex(result.index)),
          check_divisions=False,
          check_categorical=False,
      )
  
      assert ddf.categorize(index=False) is ddf
  
      # Non-object dtype
      ddf = dd.from_pandas(
          result.set_index(result.A.rename("idx")), npartitions=5
      )
      result = ddf.compute()
  
      ddf2 = ddf.categorize(index=True)
      assert ddf2.index.cat.known
      assert_eq(
          ddf2,
          result.set_index(pd.CategoricalIndex(result.index)),
          check_divisions=False,
          check_categorical=False,
      )
  
      assert ddf.categorize() is ddf
  
imports: from __future__ import annotations
  import contextlib
  import operator
  import warnings
  import numpy
  import pandas
  import pytest
  import dask
  import dask.dataframe
  from dask.dataframe import _compat
  from dask.dataframe._compat import PANDAS_GE_150, PANDAS_GE_200, PANDAS_GE_210, tm
  from dask.dataframe._pyarrow import to_pyarrow_string
  from dask.dataframe.core import _concat
  from dask.dataframe.utils import assert_eq, clear_known_categories, get_string_dtype, make_meta, pyarrow_strings_enabled
label_desc: Use image node_id 5 for calling a global function with example usage: test_categorize_index() without return types