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: Convert an ndarray or an iterable of heterogeneous-shaped ndarrays to an array
  of heterogeneous-shaped, homogeneous-typed tensors.
  
  Args:
      arr: An ndarray or an iterable of heterogeneous-shaped ndarrays.
  
  Returns:
      An ArrowVariableShapedTensorArray containing len(arr) tensors of
      heterogeneous shape.
docstr_tok: ["Convert","an","ndarray","or","an","iterable","of","heterogeneous-shaped","ndarrays","to","an","array","of","heterogeneous-shaped",",","homogeneous-typed","tensors",".","Args",":","arr",":","An","ndarray","or","an","iterable","of","heterogeneous-shaped","ndarrays",".","Returns",":","An","ArrowVariableShapedTensorArray","containing","len","(","arr",")","tensors","of","heterogeneous","shape","."]
code: def from_numpy(
      cls, arr: Union[np.ndarray, List[np.ndarray], Tuple[np.ndarray]]
  ) -> "ArrowVariableShapedTensorArray":
      """
      Convert an ndarray or an iterable of heterogeneous-shaped ndarrays to an array
      of heterogeneous-shaped, homogeneous-typed tensors.
  
      Args:
          arr: An ndarray or an iterable of heterogeneous-shaped ndarrays.
  
      Returns:
          An ArrowVariableShapedTensorArray containing len(arr) tensors of
          heterogeneous shape.
      """
      # Implementation note - Arrow representation of ragged tensors:
      #
      # We represent an array of ragged tensors using a struct array containing two
      # fields:
      #  - data: a variable-sized list array, where each element in the array is a
      #    tensor element stored in a 1D (raveled) variable-sized list of the
      #    underlying scalar data type.
      #  - shape: a variable-sized list array containing the shapes of each tensor
      #    element.
      if not isinstance(arr, (list, tuple, np.ndarray)):
          raise ValueError(
              "ArrowVariableShapedTensorArray can only be constructed from an "
              f"ndarray or a list/tuple of ndarrays, but got: {type(arr)}"
          )
      if len(arr) == 0:
          # Empty ragged tensor arrays are not supported.
          raise ValueError(
              "Creating empty ragged tensor arrays is not supported."
          )
  
      # Whether all subndarrays are contiguous views of the same ndarray.
      shapes, sizes, raveled = [], [], []
      ndim = None
      for a in arr:
          a = np.asarray(a)
          if ndim is not None and a.ndim != ndim:
              raise ValueError(
                  "ArrowVariableShapedTensorArray only supports tensor elements that "
                  "all have the same number of dimensions, but got tensor elements "
                  f"with dimensions: {ndim}, {a.ndim}"
              )
          ndim = a.ndim
          shapes.append(a.shape)
          sizes.append(a.size)
          # Convert to 1D array view; this should be zero-copy in the common case.
          # NOTE: If array is not in C-contiguous order, this will convert it to
          # C-contiguous order, incurring a copy.
          a = np.ravel(a, order="C")
          raveled.append(a)
      # Get size offsets and total size.
      sizes = np.array(sizes)
      size_offsets = np.cumsum(sizes)
      total_size = size_offsets[-1]
      # Concatenate 1D views into a contiguous 1D array.
      if all(
          _is_contiguous_view(curr, prev)
          for prev, curr in _pairwise(raveled)
      ):
          # An optimized zero-copy path if raveled tensor elements are already
          # contiguous in memory, e.g. if this tensor array has already done a
          # roundtrip through our Arrow representation.
          np_data_buffer = raveled[-1].base
      else:
          np_data_buffer = np.concatenate(raveled)
      dtype = np_data_buffer.dtype
      pa_dtype = pa.from_numpy_dtype(dtype)
      if pa.types.is_string(pa_dtype):
          if dtype.byteorder == ">" or (
              dtype.byteorder == "=" and sys.byteorder == "big"
          ):
              raise ValueError(
                  "Only little-endian string tensors are supported, "
                  f"but got: {dtype}"
              )
          pa_dtype = pa.binary(dtype.itemsize)
      if dtype.type is np.bool_:
          # NumPy doesn't represent boolean arrays as bit-packed, so we manually
          # bit-pack the booleans before handing the buffer off to Arrow.
          # NOTE: Arrow expects LSB bit-packed ordering.
          # NOTE: This creates a copy.
          np_data_buffer = np.packbits(
              np_data_buffer, bitorder="little"
          )
      data_buffer = pa.py_buffer(np_data_buffer)
      # Construct underlying data array.
      value_array = pa.Array.from_buffers(
          pa_dtype, total_size, [None, data_buffer]
      )
      # Construct array for offsets into the 1D data array, where each offset
      # corresponds to a tensor element.
      size_offsets = np.insert(size_offsets, 0, 0)
      offset_array = pa.array(size_offsets)
      data_array = pa.ListArray.from_arrays(offset_array, value_array)
      # We store the tensor element shapes so we can reconstruct each tensor when
      # converting back to NumPy ndarrays.
      shape_array = pa.array(shapes)
      # Build storage array containing tensor data and the tensor element shapes.
      storage = pa.StructArray.from_arrays(
          [data_array, shape_array],
          ["data", "shape"],
      )
      type_ = ArrowVariableShapedTensorType(pa_dtype, ndim)
      return pa.ExtensionArray.from_storage(type_, storage)
  
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 1 for calling the ArrowVariableShapedTensorArray obj's underlying member method code with example usage: obj.from_numpy(cls, arr) and returns: pa