code: def _ensure_nanosecond_dtype(dtype: DtypeObj) -> None:
      """
      Convert dtypes with granularity less than nanosecond to nanosecond
  
      >>> _ensure_nanosecond_dtype(np.dtype("M8[us]"))
  
      >>> _ensure_nanosecond_dtype(np.dtype("M8[D]"))
      Traceback (most recent call last):
          ...
      TypeError: dtype=datetime64[D] is not supported. Supported resolutions are 's', 'ms', 'us', and 'ns'
  
      >>> _ensure_nanosecond_dtype(np.dtype("m8[ps]"))
      Traceback (most recent call last):
          ...
      TypeError: dtype=timedelta64[ps] is not supported. Supported resolutions are 's', 'ms', 'us', and 'ns'
      """  # noqa: E501
      msg = (
          f"The '{dtype.name}' dtype has no unit. "
          f"Please pass in '{dtype.name}[ns]' instead."
      )
  
      # unpack e.g. SparseDtype
      dtype = getattr(dtype, "subtype", dtype)
  
      if not isinstance(dtype, np.dtype):
          # i.e. datetime64tz
          pass
  
      elif dtype.kind in "mM":
          if not is_supported_dtype(dtype):
              # pre-2.0 we would silently swap in nanos for lower-resolutions,
              #  raise for above-nano resolutions
              if dtype.name in ["datetime64", "timedelta64"]:
                  raise ValueError(msg)
              # TODO: ValueError or TypeError? existing test
              #  test_constructor_generic_timestamp_bad_frequency expects TypeError
              raise TypeError(
                  f"dtype={dtype} is not supported. Supported resolutions are 's', "
                  "'ms', 'us', and 'ns'"
              )
  
imports: from __future__ import annotations
  import datetime
  import functools
  from typing import TYPE_CHECKING, Any, Literal, TypeVar, cast, overload
  import warnings
  import numpy
  from pandas._config import using_pyarrow_string_dtype
  from pandas._libs import Interval, Period, lib
  from pandas._libs.missing import NA, NAType, checknull
  from pandas._libs.tslibs import NaT, OutOfBoundsDatetime, OutOfBoundsTimedelta, Timedelta, Timestamp, is_supported_dtype
  from pandas._libs.tslibs.timedeltas import array_to_timedelta64
  from pandas.compat.numpy import np_version_gt2
  from pandas.errors import IntCastingNaNError, LossySetitemError
  from pandas.core.dtypes.common import ensure_int8, ensure_int16, ensure_int32, ensure_int64, ensure_object, ensure_str, is_bool, is_complex, is_float, is_integer, is_object_dtype, is_scalar, is_string_dtype, pandas_dtype
  from pandas.core.dtypes.dtypes import ArrowDtype, BaseMaskedDtype, CategoricalDtype, DatetimeTZDtype, ExtensionDtype, IntervalDtype, PandasExtensionDtype, PeriodDtype
  from pandas.core.dtypes.generic import ABCExtensionArray, ABCIndex, ABCSeries
  from pandas.core.dtypes.inference import is_list_like
  from pandas.core.dtypes.missing import is_valid_na_for_dtype, isna, na_value_for_dtype, notna
  from pandas.io._util import _arrow_dtype_mapping
label_desc: Use image node_id 33 for calling a global function with example usage: _ensure_nanosecond_dtype(dtype) without return types