code: def ensure_wrapped_if_datetimelike(arr):
      """
      Wrap datetime64 and timedelta64 ndarrays in DatetimeArray/TimedeltaArray.
      """
      if isinstance(arr, np.ndarray):
          if arr.dtype.kind == "M":
              from pandas.core.arrays import DatetimeArray
  
              return DatetimeArray._from_sequence(arr)
  
          elif arr.dtype.kind == "m":
              from pandas.core.arrays import TimedeltaArray
  
              return TimedeltaArray._from_sequence(arr)
  
      return arr
  
imports: from __future__ import annotations
  from typing import TYPE_CHECKING, Optional, Sequence, Union, cast, overload
  import numpy
  from numpy import ma
  from pandas._libs import lib
  from pandas._libs.tslibs.period import Period
  from pandas._typing import AnyArrayLike, ArrayLike, Dtype, DtypeObj, T
  from pandas.core.dtypes.base import ExtensionDtype, _registry
  from pandas.core.dtypes.cast import construct_1d_arraylike_from_scalar, construct_1d_object_array_from_listlike, maybe_cast_to_datetime, maybe_cast_to_integer_array, maybe_convert_platform, maybe_infer_to_datetimelike, maybe_promote
  from pandas.core.dtypes.common import is_datetime64_ns_dtype, is_dtype_equal, is_extension_array_dtype, is_integer_dtype, is_list_like, is_object_dtype, is_timedelta64_ns_dtype
  from pandas.core.dtypes.dtypes import PandasDtype
  from pandas.core.dtypes.generic import ABCDataFrame, ABCExtensionArray, ABCIndex, ABCPandasArray, ABCRangeIndex, ABCSeries
  from pandas.core.dtypes.missing import isna
  import pandas.core.common
label_desc: Use image node_id 5 for calling a global function with example usage: ensure_wrapped_if_datetimelike(arr) and returns: arr, DatetimeArray, TimedeltaArray