code: def test_custom_arrow_data_serializer(
      ray_start_regular_shared, data, cap_mult
  ):
      if len(data) == 0:
          data = pa.table({"a": []})
      else:
          data = pa.Table.from_arrays(
              [data, data, pa.array(range(1000), type=pa.int32())],
              schema=pa.schema(
                  [
                      pa.field("arr1", data.type),
                      pa.field("arr2", data.type),
                      pa.field("arr3", pa.int32()),
                  ],
                  metadata={b"foo": b"bar"},
              ),
          )
      ray._private.worker.global_worker.get_serialization_context()
      data.validate()
      pyarrow_version = parse_version(_get_pyarrow_version())
      if pyarrow_version >= parse_version("7.0.0"):
          # get_total_buffer_size API was added in Arrow 7.0.0.
          buf_size = data.get_total_buffer_size()
      # Create a zero-copy slice view of data.
      view = data.slice(10, 10)
      s_arr = pickle.dumps(data)
      s_view = pickle.dumps(view)
      post_slice = pickle.loads(s_view)
      post_slice.validate()
      # Check for round-trip equality.
      assert view.equals(post_slice), post_slice
      # Check that the slice view was truncated upon serialization.
      assert len(s_view) <= cap_mult * len(s_arr)
      for column, pre_column in zip(post_slice.columns, view.columns):
          # Check that offset was reset on slice.
          if column.num_chunks > 0:
              assert column.chunk(0).offset == 0
          # Check that null count was either properly cached or recomputed.
          assert column.null_count == pre_column.null_count
      if pyarrow_version >= parse_version("7.0.0"):
          # Check that slice buffer only contains slice data.
          slice_buf_size = post_slice.get_total_buffer_size()
          if buf_size > 0:
              assert (
                  buf_size / slice_buf_size
                  - len(data) / len(post_slice)
                  < 100
              )
  
imports: import logging
  import os
  import sys
  from unittest import mock
  import numpy
  import pyarrow
  import pyarrow.parquet
  import pytest
  from packaging.version import parse
  from pytest_lazyfixture import lazy_fixture
  import ray
  import ray.cloudpickle
  from ray._private.arrow_serialization import _align_bit_offset, _bytes_for_bits, _copy_bitpacked_buffer_if_needed, _copy_buffer_if_needed, _copy_normal_buffer_if_needed, _copy_offsets_buffer_if_needed
  from ray._private.utils import _get_pyarrow_version
  from ray.data.extensions.tensor_extension import ArrowTensorArray, ArrowVariableShapedTensorArray
  from ray.tests.conftest import *
label_desc: Use image node_id 33 for calling a global function with example usage: test_custom_arrow_data_serializer(ray_start_regular_shared, data, cap_mult) without return types