code: def test_categorical_index_survives_roundtrip():
      # ARROW-3652, addressed by ARROW-3246
      df = pd.DataFrame([["a", "b"], ["c", "d"]], columns=["c1", "c2"])
      df["c1"] = df["c1"].astype("category")
      df = df.set_index(["c1"])
  
      table = pa.Table.from_pandas(df)
      bos = pa.BufferOutputStream()
      pq.write_table(table, bos)
      ref_df = pq.read_pandas(bos.getvalue()).to_pandas()
      assert isinstance(ref_df.index, pd.CategoricalIndex)
      assert ref_df.index.equals(df.index)
  
imports: import io
  import json
  import numpy
  import pytest
  import pyarrow
  from pyarrow.fs import LocalFileSystem, SubTreeFileSystem
  from pyarrow.util import guid
  from pyarrow.vendored.version import Version
label_desc: Use image node_id 18 for calling a global function with example usage: test_categorical_index_survives_roundtrip() without return types