code: def _wrap_results(result, dtype, fill_value=None):
      """wrap our results if needed"""
  
      if is_datetime64_dtype(dtype) or is_datetime64tz_dtype(dtype):
          if fill_value is None:
              # GH#24293
              fill_value = iNaT
          if not isinstance(result, np.ndarray):
              tz = getattr(dtype, "tz", None)
              assert not isna(
                  fill_value
              ), "Expected non-null fill_value"
              if result == fill_value:
                  result = np.nan
              result = tslibs.Timestamp(result, tz=tz)
          else:
              result = result.view(dtype)
      elif is_timedelta64_dtype(dtype):
          if not isinstance(result, np.ndarray):
              if result == fill_value:
                  result = np.nan
  
              # raise if we have a timedelta64[ns] which is too large
              if np.fabs(result) > _int64_max:
                  raise ValueError("overflow in timedelta operation")
  
              result = tslibs.Timedelta(result, unit="ns")
          else:
              result = result.astype("i8").view(dtype)
  
      return result
  
imports: from distutils.version import LooseVersion
  import functools
  import itertools
  import operator
  import warnings
  import numpy
  from pandas._libs import iNaT, lib, tslibs
  import pandas.compat
  from pandas.core.dtypes.cast import _int64_max, maybe_upcast_putmask
  from pandas.core.dtypes.common import _get_dtype, is_any_int_dtype, is_bool_dtype, is_complex, is_complex_dtype, is_datetime64_dtype, is_datetime64tz_dtype, is_datetime_or_timedelta_dtype, is_float, is_float_dtype, is_integer, is_integer_dtype, is_numeric_dtype, is_object_dtype, is_scalar, is_timedelta64_dtype, pandas_dtype
  from pandas.core.dtypes.dtypes import DatetimeTZDtype
  from pandas.core.dtypes.missing import isna, na_value_for_dtype, notna
  import pandas.core.common
  from pandas.core.config import get_option
label_desc: Use image node_id 8 for calling a global function with example usage: _wrap_results(result, dtype, fill_value) and returns: result