code: def test_copy_offsets_buffer_if_needed(
      arr_type, expected_offset_type
  ):
      offset_arr = pa.array(
          [0, 1, 3, 6, 10, 15, 21], type=expected_offset_type
      )
      buf = offset_arr.buffers()[1]
      offset = 2
      length = 3
      (
          offset_buf,
          data_offset,
          data_length,
      ) = _copy_offsets_buffer_if_needed(buf, arr_type, offset, length)
      assert data_offset == 3
      assert data_length == 12
      truncated_offset_arr = pa.Array.from_buffers(
          expected_offset_type, length, [None, offset_buf]
      )
      expected_offset_arr = pa.array(
          [0, 3, 7], type=expected_offset_type
      )
      assert truncated_offset_arr.equals(expected_offset_arr)
  
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 7 for calling a global function with example usage: test_copy_offsets_buffer_if_needed(arr_type, expected_offset_type) without return types