class_docstr: An array of heterogeneous-shaped, homogeneous-typed tensors.
  
  This is the Arrow side of TensorArray for tensor elements that have differing
  shapes. Note that this extension only supports non-ragged tensor elements; i.e.,
  when considering each tensor element in isolation, they must have a well-defined
  shape. This extension also only supports tensor elements that all have the same
  number of dimensions.
  
  See Arrow docs for customizing extension arrays:
  https://arrow.apache.org/docs/python/extending_types.html#custom-extension-array-class
class_docstr_tok: ["An","array","of","heterogeneous-shaped",",","homogeneous-typed","tensors",".","This","is","the","Arrow","side","of","TensorArray","for","tensor","elements","that","have","differing","shapes",".","Note","that","this","extension","only","supports","non-ragged","tensor","elements",";","i.e.",",","when","considering","each","tensor","element","in","isolation",",","they","must","have","a","well-defined","shape",".","This","extension","also","only","supports","tensor","elements","that","all","have","the","same","number","of","dimensions",".","See","Arrow","docs","for","customizing","extension","arrays",":","https",":","\/\/arrow.apache.org\/docs\/python\/extending_types.html","#","custom-extension-array-class"]
docstr: Helper for getting either an element of the array of tensors as an ndarray, or
  the entire array of tensors as a single ndarray.
  
  Args:
      index: The index of the tensor element that we wish to return as an
          ndarray. If not given, the entire array of tensors is returned as an
          ndarray.
      zero_copy_only: If True, an exception will be raised if the conversion to a
          NumPy array would require copying the underlying data (e.g. in presence
          of nulls, or for non-primitive types). This argument is currently
          ignored, so zero-copy isn't enforced even if this argument is true.
  
  Returns:
      The corresponding tensor element as an ndarray if an index was given, or
      the entire array of tensors as an ndarray otherwise.
docstr_tok: ["Helper","for","getting","either","an","element","of","the","array","of","tensors","as","an","ndarray",",","or","the","entire","array","of","tensors","as","a","single","ndarray",".","Args",":","index",":","The","index","of","the","tensor","element","that","we","wish","to","return","as","an","ndarray",".","If","not","given",",","the","entire","array","of","tensors","is","returned","as","an","ndarray",".","zero_copy_only",":","If","True",",","an","exception","will","be","raised","if","the","conversion","to","a","NumPy","array","would","require","copying","the","underlying","data","(","e.g",".","in","presence","of","nulls",",","or","for","non-primitive","types",")",".","This","argument","is","currently","ignored",",","so","zero-copy","is","n't","enforced","even","if","this","argument","is","true",".","Returns",":","The","corresponding","tensor","element","as","an","ndarray","if","an","index","was","given",",","or","the","entire","array","of","tensors","as","an","ndarray","otherwise","."]
code: def _to_numpy(
      self, index: Optional[int] = None, zero_copy_only: bool = False
  ):
      """
      Helper for getting either an element of the array of tensors as an ndarray, or
      the entire array of tensors as a single ndarray.
  
      Args:
          index: The index of the tensor element that we wish to return as an
              ndarray. If not given, the entire array of tensors is returned as an
              ndarray.
          zero_copy_only: If True, an exception will be raised if the conversion to a
              NumPy array would require copying the underlying data (e.g. in presence
              of nulls, or for non-primitive types). This argument is currently
              ignored, so zero-copy isn't enforced even if this argument is true.
  
      Returns:
          The corresponding tensor element as an ndarray if an index was given, or
          the entire array of tensors as an ndarray otherwise.
      """
      # TODO(Clark): Enforce zero_copy_only.
      # TODO(Clark): Support strides?
      if index is None:
          # Get individual ndarrays for each tensor element.
          arrs = [
              self._to_numpy(i, zero_copy_only)
              for i in range(len(self))
          ]
          # Return ragged NumPy ndarray in the ndarray of ndarray pointers
          # representation.
          return create_ragged_ndarray(arrs)
      data = self.storage.field("data")
      shapes = self.storage.field("shape")
  
      shape = shapes[index].as_py()
      value_type = data.type.value_type
      offset = data.offsets[index].as_py()
      data_buffer = data.buffers()[3]
      return _to_ndarray_helper(shape, value_type, offset, data_buffer)
  
imports: import itertools
  import json
  import sys
  from typing import Iterable, Optional, Tuple, List, Sequence, Union
  from packaging.version import parse
  import numpy
  import pyarrow
  from ray.air.util.tensor_extensions.utils import _is_ndarray_variable_shaped_tensor, create_ragged_ndarray
  from ray._private.utils import _get_pyarrow_version
  from ray.util.annotations import PublicAPI
label_desc: Use image node_id 2 for calling the ArrowVariableShapedTensorArray obj's underlying member method code with example usage: obj._to_numpy(index, zero_copy_only) and returns: _to_ndarray_helper, create_ragged_ndarray