code: def test_categorical_basic():
      cat = pd.Categorical(
          ["a", "a", "b", "c", "a"], categories=["a", "b", "c"]
      )
      cudf_cat = cudf.Index(cat)
  
      pdsr = pd.Series(cat, index=["p", "q", "r", "s", "t"])
      sr = cudf.Series(cat, index=["p", "q", "r", "s", "t"])
      assert_eq(pdsr.cat.codes, sr.cat.codes, check_dtype=False)
  
      # Test attributes
      assert_eq(pdsr.cat.categories, sr.cat.categories)
      assert pdsr.cat.ordered == sr.cat.ordered
  
      np.testing.assert_array_equal(
          pdsr.cat.codes.values, sr.cat.codes.to_numpy()
      )
  
      string = str(sr)
      expect_str = """
  p a
  q a
  r b
  s c
  t a
  """
      assert all(
          x == y for x, y in zip(string.split(), expect_str.split())
      )
      assert_eq(cat.codes, cudf_cat.codes.to_numpy())
  
imports: import operator
  import string
  import warnings
  from contextlib import contextmanager
  from textwrap import dedent
  import numpy
  import pandas
  import pytest
  import cudf
  from cudf.core._compat import PANDAS_GE_134
  from cudf.testing._utils import NUMERIC_TYPES, assert_eq, assert_exceptions_equal, expect_warning_if
label_desc: Use image node_id 4 for calling a global function with example usage: test_categorical_basic() without return types