code: def test_categorical_accessor_presence():
      df = pd.DataFrame(
          {"x": list("a" * 5 + "b" * 5 + "c" * 5), "y": range(15)}
      )
      df.x = df.x.astype("category")
      ddf = dd.from_pandas(df, npartitions=2)
  
      assert "cat" in dir(ddf.x)
      assert "cat" not in dir(ddf.y)
      assert hasattr(ddf.x, "cat")
      assert not hasattr(ddf.y, "cat")
  
      df2 = df.set_index(df.x)
      ddf2 = dd.from_pandas(df2, npartitions=2, sort=False)
      assert hasattr(ddf2.index, "categories")
      assert not hasattr(ddf.index, "categories")
  
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 9 for calling a global function with example usage: test_categorical_accessor_presence() without return types