code: def test_categorical_basic(data):
      cat = data.copy()
      pdsr = pd.Series(cat)
      sr = Series(cat)
      dsr = dgd.from_cudf(sr, npartitions=2)
      result = dsr.compute()
      np.testing.assert_array_equal(
          cat.codes, result.cat.codes.values_host
      )
  
      assert dsr.dtype.to_pandas() == pdsr.dtype
      # Test attributes
      assert pdsr.cat.ordered == dsr.cat.ordered
  
      assert_eq(pdsr.cat.categories, dsr.cat.categories)
  
      np.testing.assert_array_equal(
          pdsr.cat.codes.values, result.cat.codes.values_host
      )
  
      string = str(result)
      expect_str = """
  0 a
  1 a
  2 b
  3 c
  4 a
  """
      assert all(
          x == y for x, y in zip(string.split(), expect_str.split())
      )
  
      df = DataFrame()
      df["a"] = ["xyz", "abc", "def"] * 10
  
      pdf = df.to_pandas()
      cddf = dgd.from_cudf(df, 1)
      cddf["b"] = cddf["a"].astype("category")
  
      ddf = dd.from_pandas(pdf, 1)
      ddf["b"] = ddf["a"].astype("category")
  
      assert_eq(ddf._meta_nonempty["b"], cddf._meta_nonempty["b"])
  
      with pytest.raises(NotImplementedError):
          cddf["b"].cat.categories
  
      with pytest.raises(NotImplementedError):
          ddf["b"].cat.categories
  
      cddf = cddf.categorize()
      ddf = ddf.categorize()
  
      assert_eq(ddf["b"].cat.categories, cddf["b"].cat.categories)
      assert_eq(ddf["b"].cat.ordered, cddf["b"].cat.ordered)
  
imports: import numpy
  import pandas
  import pytest
  from pandas.testing import assert_series_equal
  from dask import dataframe
  from cudf import DataFrame, Series, date_range
  from cudf.testing._utils import assert_eq, does_not_raise
  import dask_cudf
label_desc: Use image node_id 12 for calling a global function with example usage: test_categorical_basic(data) without return types