code: def test_arrow_tensor_array_getitem(chunked):
      outer_dim = 3
      inner_shape = (2, 2, 2)
      shape = (outer_dim,) + inner_shape
      num_items = np.prod(np.array(shape))
      arr = np.arange(num_items).reshape(shape)
  
      t_arr = ArrowTensorArray.from_numpy(arr)
      if chunked:
          t_arr = pa.chunked_array(t_arr)
  
      pyarrow_version = parse_version(_get_pyarrow_version())
      if (
          chunked
          and pyarrow_version >= parse_version("8.0.0")
          and pyarrow_version < parse_version("9.0.0")
      ):
          for idx in range(outer_dim):
              item = t_arr[idx]
              assert isinstance(item, pa.ExtensionScalar)
              item = item.type._extension_scalar_to_ndarray(item)
              np.testing.assert_array_equal(item, arr[idx])
      else:
          for idx in range(outer_dim):
              np.testing.assert_array_equal(t_arr[idx], arr[idx])
  
      # Test __iter__.
      for t_subarr, subarr in zip(t_arr, arr):
          np.testing.assert_array_equal(t_subarr, subarr)
  
      # Test to_pylist.
      np.testing.assert_array_equal(t_arr.to_pylist(), list(arr))
  
      # Test slicing and indexing.
      t_arr2 = t_arr[1:]
      if chunked:
          # For extension arrays, ChunkedArray.to_numpy() concatenates chunk storage
          # arrays and calls to_numpy() on the resulting array, which returns the wrong
          # ndarray.
          # TODO(Clark): Fix this in Arrow by (1) providing an ExtensionArray hook for
          # concatenation, and (2) using that + a to_numpy() call on the resulting
          # ExtensionArray.
          t_arr2_npy = t_arr2.chunk(0).to_numpy()
      else:
          t_arr2_npy = t_arr2.to_numpy()
  
      np.testing.assert_array_equal(t_arr2_npy, arr[1:])
  
      if (
          chunked
          and pyarrow_version >= parse_version("8.0.0")
          and pyarrow_version < parse_version("9.0.0")
      ):
          for idx in range(1, outer_dim):
              item = t_arr2[idx - 1]
              assert isinstance(item, pa.ExtensionScalar)
              item = item.type._extension_scalar_to_ndarray(item)
              np.testing.assert_array_equal(item, arr[idx])
      else:
          for idx in range(1, outer_dim):
              np.testing.assert_array_equal(t_arr2[idx - 1], arr[idx])
  
imports: import itertools
  import numpy
  import pandas
  from packaging.version import parse
  import pyarrow
  import pytest
  from ray.air.util.tensor_extensions.arrow import ArrowTensorArray, ArrowTensorType, ArrowVariableShapedTensorArray, ArrowVariableShapedTensorType
  from ray.air.util.tensor_extensions.pandas import TensorArray, TensorDtype
  from ray.air.util.tensor_extensions.utils import create_ragged_ndarray
  from ray._private.utils import _get_pyarrow_version
label_desc: Use image node_id 20 for calling a global function with example usage: test_arrow_tensor_array_getitem(chunked) without return types