code: def _convert_datetimes(
      sas_datetimes: pd.Series, unit: str
  ) -> pd.Series:
      """
      Convert to Timestamp if possible, otherwise to datetime.datetime.
      SAS float64 lacks precision for more than ms resolution so the fit
      to datetime.datetime is ok.
  
      Parameters
      ----------
      sas_datetimes : {Series, Sequence[float]}
         Dates or datetimes in SAS
      unit : {'d', 's'}
         "d" if the floats represent dates, "s" for datetimes
  
      Returns
      -------
      Series
         Series of datetime64 dtype or datetime.datetime.
      """
      td = (_sas_origin - _unix_origin).as_unit("s")
      if unit == "s":
          millis = cast_from_unit_vectorized(
              sas_datetimes._values, unit="s", out_unit="ms"
          )
          dt64ms = millis.view("M8[ms]") + td
          return pd.Series(
              dt64ms, index=sas_datetimes.index, copy=False
          )
      else:
          vals = np.array(sas_datetimes, dtype="M8[D]") + td
          return pd.Series(
              vals, dtype="M8[s]", index=sas_datetimes.index, copy=False
          )
  
imports: from __future__ import annotations
  from collections import abc
  from datetime import datetime, timedelta
  import sys
  from typing import TYPE_CHECKING
  import numpy
  from pandas._libs.byteswap import read_double_with_byteswap, read_float_with_byteswap, read_uint16_with_byteswap, read_uint32_with_byteswap, read_uint64_with_byteswap
  from pandas._libs.sas import Parser, get_subheader_index
  from pandas._libs.tslibs.conversion import cast_from_unit_vectorized
  from pandas.errors import EmptyDataError
  import pandas
  from pandas import DataFrame, Timestamp, isna
  from pandas.io.common import get_handle
  import pandas.io.sas.sas_constants
  from pandas.io.sas.sasreader import ReaderBase
label_desc: Use image node_id 2 for calling a global function with example usage: _convert_datetimes(sas_datetimes, unit) and returns: pd, pd