code: def _wrap_results(result, dtype: np.dtype, fill_value=None):
      """wrap our results if needed"""
      if result is NaT:
          pass
  
      elif is_datetime64_any_dtype(dtype):
          if fill_value is None:
              # GH#24293
              fill_value = iNaT
          if not isinstance(result, np.ndarray):
              assert not isna(
                  fill_value
              ), "Expected non-null fill_value"
              if result == fill_value:
                  result = np.nan
  
              if isna(result):
                  result = np.datetime64("NaT", "ns").astype(dtype)
              else:
                  result = np.int64(result).view(dtype)
              # retain original unit
              result = result.astype(dtype, copy=False)
          else:
              # If we have float dtype, taking a view will give the wrong result
              result = result.astype(dtype)
      elif is_timedelta64_dtype(dtype):
          if not isinstance(result, np.ndarray):
              if result == fill_value or np.isnan(result):
                  result = np.timedelta64("NaT").astype(dtype)
  
              elif np.fabs(result) > lib.i8max:
                  # raise if we have a timedelta64[ns] which is too large
                  raise ValueError("overflow in timedelta operation")
              else:
                  # return a timedelta64 with the original unit
                  result = np.int64(result).astype(dtype, copy=False)
  
          else:
              result = result.astype("m8[ns]").view(dtype)
  
      return result
  
imports: from __future__ import annotations
  import functools
  import itertools
  import operator
  from typing import Any, Callable, cast
  import warnings
  import numpy
  from pandas._config import get_option
  from pandas._libs import NaT, NaTType, iNaT, lib
  from pandas._typing import ArrayLike, AxisInt, CorrelationMethod, Dtype, DtypeObj, F, Scalar, Shape, npt
  from pandas.compat._optional import import_optional_dependency
  from pandas.util._exceptions import find_stack_level
  from pandas.core.dtypes.common import is_any_int_dtype, is_bool_dtype, is_complex, is_datetime64_any_dtype, is_float, is_float_dtype, is_integer, is_integer_dtype, is_numeric_dtype, is_object_dtype, is_scalar, is_timedelta64_dtype, needs_i8_conversion, pandas_dtype
  from pandas.core.dtypes.dtypes import PeriodDtype
  from pandas.core.dtypes.missing import isna, na_value_for_dtype, notna
  from pandas.core.construction import extract_array
label_desc: Use image node_id 8 for calling a global function with example usage: _wrap_results(result, dtype, fill_value) and returns: result