code: def _unwrap_ndarray_object_type_if_needed(
      arr: np.ndarray,
  ) -> np.ndarray:
      """Unwrap an object-dtyped NumPy ndarray containing ndarray pointers into a single
      contiguous ndarray, if needed/possible.
      """
      if arr.dtype.type is np.object_:
          try:
              # Try to convert the NumPy ndarray to a non-object dtype.
              arr = np.array([np.asarray(v) for v in arr])
          except Exception:
              # This may fail if the subndarrays are of heterogeneous shape
              pass
      return arr
  
imports: from enum import Enum
  from typing import Dict, Union, List, TYPE_CHECKING
  import warnings
  import numpy
  from ray.air.data_batch_type import DataBatchType
  from ray.air.constants import TENSOR_COLUMN_NAME
  from ray.util.annotations import Deprecated, DeveloperAPI
label_desc: Use image node_id 8 for calling a global function with example usage: _unwrap_ndarray_object_type_if_needed(arr) and returns: arr