code: def _df_to_pyarrow_table_zero_copy(df: Any) -> pa.Table:
      dfi = df.__dataframe__(allow_copy=False)
      if _dfi_contains_categorical_data(dfi):
          raise TypeError(
              "Polars can not currently guarantee zero-copy conversion from Arrow for categorical columns"
              "\n\nSet `allow_copy=True` or cast categorical columns to string first."
          )
  
      if isinstance(df, pa.Table):
          return df
      elif isinstance(df, pa.RecordBatch):
          return pa.Table.from_batches([df])
      else:
          return pa.interchange.from_dataframe(dfi, allow_copy=False)
  
file_path: polars/py-polars/polars/interchange/from_dataframe.py
imports: from __future__ import annotations
  from typing import TYPE_CHECKING, Any
  import polars._reexport
  from polars.convert import from_arrow
  from polars.dependencies import _PYARROW_AVAILABLE
  from polars.dependencies import pyarrow
  from polars.interchange.dataframe import PolarsDataFrame
  from polars.utils.various import parse_version
label_desc: Use image node_id 3 for calling a global function with example usage: _df_to_pyarrow_table_zero_copy(df) and returns: df, pa, pa