code: def bool_column_to_array(
      col: ColumnObject,
      allow_copy: bool = True,
  ) -> pa.Array:
      """
      Convert a column holding boolean dtype to a PyArrow array.
  
      Parameters
      ----------
      col : ColumnObject
      allow_copy : bool, default: True
          Whether to allow copying the memory to perform the conversion
          (if false then zero-copy approach is requested).
  
      Returns
      -------
      pa.Array
      """
      buffers = col.get_buffers()
      size = buffers["data"][1][1]
  
      # If booleans are byte-packed a copy to bit-packed will be made
      if size == 8 and not allow_copy:
          raise RuntimeError(
              "Boolean column will be casted from uint8 and a copy "
              "is required which is forbidden by allow_copy=False"
          )
  
      data_type = col.dtype
      data = buffers_to_array(
          buffers, data_type, col.size(), col.describe_null, col.offset
      )
      if size == 8:
          data = pc.cast(data, pa.bool_())
  
      return data
  
file_path: arrow/python/pyarrow/interchange/from_dataframe.py
imports: from __future__ import annotations
  from typing import Any, Tuple
  from pyarrow.interchange.column import DtypeKind, ColumnBuffers, ColumnNullType
  import pyarrow
  import re
  import pyarrow.compute
  from pyarrow.interchange.column import Dtype
label_desc: Use image node_id 5 for calling a global function with example usage: bool_column_to_array(col, allow_copy) and returns: data