class_docstr: An array of fixed-shape, homogeneous-typed tensors.
  
  This is the Arrow side of TensorArray.
  
  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","fixed-shape",",","homogeneous-typed","tensors",".","This","is","the","Arrow","side","of","TensorArray",".","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 ndarrays to an array of homogeneous-typed
  tensors. If given fixed-shape tensor elements, this will return an
  ``ArrowTensorArray``; if given variable-shape tensor elements, this will return
  an ``ArrowVariableShapedTensorArray``.
  
  Args:
      arr: An ndarray or an iterable of ndarrays.
  
  Returns:
      - If fixed-shape tensor elements, an ``ArrowTensorArray`` containing
        ``len(arr)`` tensors of fixed shape.
      - If variable-shaped tensor elements, an ``ArrowVariableShapedTensorArray``
        containing ``len(arr)`` tensors of variable shape.
      - If scalar elements, a ``pyarrow.Array``.
docstr_tok: ["Convert","an","ndarray","or","an","iterable","of","ndarrays","to","an","array","of","homogeneous-typed","tensors",".","If","given","fixed-shape","tensor","elements",",","this","will","return","an","``","ArrowTensorArray","``",";","if","given","variable-shape","tensor","elements",",","this","will","return","an","``","ArrowVariableShapedTensorArray","``",".","Args",":","arr",":","An","ndarray","or","an","iterable","of","ndarrays",".","Returns",":","-","If","fixed-shape","tensor","elements",",","an","``","ArrowTensorArray","``","containing","``","len","(","arr",")","``","tensors","of","fixed","shape",".","-","If","variable-shaped","tensor","elements",",","an","``","ArrowVariableShapedTensorArray","``","containing","``","len","(","arr",")","``","tensors","of","variable","shape",".","-","If","scalar","elements",",","a","``","pyarrow.Array","``","."]
code: def from_numpy(
      cls, arr: Union[np.ndarray, Iterable[np.ndarray]]
  ) -> Union["ArrowTensorArray", "ArrowVariableShapedTensorArray"]:
      """
      Convert an ndarray or an iterable of ndarrays to an array of homogeneous-typed
      tensors. If given fixed-shape tensor elements, this will return an
      ``ArrowTensorArray``; if given variable-shape tensor elements, this will return
      an ``ArrowVariableShapedTensorArray``.
  
      Args:
          arr: An ndarray or an iterable of ndarrays.
  
      Returns:
          - If fixed-shape tensor elements, an ``ArrowTensorArray`` containing
            ``len(arr)`` tensors of fixed shape.
          - If variable-shaped tensor elements, an ``ArrowVariableShapedTensorArray``
            containing ``len(arr)`` tensors of variable shape.
          - If scalar elements, a ``pyarrow.Array``.
      """
      if (
          isinstance(arr, (list, tuple))
          and arr
          and isinstance(arr[0], np.ndarray)
      ):
          # Stack ndarrays and pass through to ndarray handling logic below.
          try:
              arr = np.stack(arr, axis=0)
          except ValueError:
              # ndarray stacking may fail if the arrays are heterogeneously-shaped.
              arr = np.array(arr, dtype=object)
      if isinstance(arr, np.ndarray):
          if len(arr) > 0 and np.isscalar(arr[0]):
              # Elements are scalar so a plain Arrow Array will suffice.
              return pa.array(arr)
          if _is_ndarray_variable_shaped_tensor(arr):
              # Tensor elements have variable shape, so we delegate to
              # ArrowVariableShapedTensorArray.
              return ArrowVariableShapedTensorArray.from_numpy(arr)
          if not arr.flags.c_contiguous:
              # We only natively support C-contiguous ndarrays.
              arr = np.ascontiguousarray(arr)
          pa_dtype = pa.from_numpy_dtype(arr.dtype)
          if pa.types.is_string(pa_dtype):
              if arr.dtype.byteorder == ">" or (
                  arr.dtype.byteorder == "=" and sys.byteorder == "big"
              ):
                  raise ValueError(
                      "Only little-endian string tensors are supported, "
                      f"but got: {arr.dtype}",
                  )
              pa_dtype = pa.binary(arr.dtype.itemsize)
          outer_len = arr.shape[0]
          element_shape = arr.shape[1:]
          total_num_items = arr.size
          num_items_per_element = (
              np.prod(element_shape) if element_shape else 1
          )
  
          # Data buffer.
          if pa.types.is_boolean(pa_dtype):
              # 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.
              arr = np.packbits(arr, bitorder="little")
          data_buffer = pa.py_buffer(arr)
          data_array = pa.Array.from_buffers(
              pa_dtype, total_num_items, [None, data_buffer]
          )
  
          # Offset buffer.
          offset_buffer = pa.py_buffer(
              cls.OFFSET_DTYPE(
                  [
                      i * num_items_per_element
                      for i in range(outer_len + 1)
                  ]
              )
          )
  
          storage = pa.Array.from_buffers(
              pa.list_(pa_dtype),
              outer_len,
              [None, offset_buffer],
              children=[data_array],
          )
          type_ = ArrowTensorType(element_shape, pa_dtype)
          return pa.ExtensionArray.from_storage(type_, storage)
      elif isinstance(arr, Iterable):
          return cls.from_numpy(list(arr))
      else:
          raise ValueError("Must give ndarray or iterable of ndarrays.")
  
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 ArrowTensorArray obj's underlying member method code with example usage: obj.from_numpy(cls, arr) and returns: pa, pa, ArrowVariableShapedTensorArray, cls