code: def is_valid_na_for_dtype(obj, dtype: DtypeObj) -> bool:
      """
      isna check that excludes incompatible dtypes
  
      Parameters
      ----------
      obj : object
      dtype : np.datetime64, np.timedelta64, DatetimeTZDtype, or PeriodDtype
  
      Returns
      -------
      bool
      """
      if not lib.is_scalar(obj) or not isna(obj):
          return False
      elif dtype.kind == "M":
          if isinstance(dtype, np.dtype):
              # i.e. not tzaware
              return not isinstance(obj, (np.timedelta64, Decimal))
          # we have to rule out tznaive dt64("NaT")
          return not isinstance(
              obj, (np.timedelta64, np.datetime64, Decimal)
          )
      elif dtype.kind == "m":
          return not isinstance(obj, (np.datetime64, Decimal))
      elif dtype.kind in ["i", "u", "f", "c"]:
          # Numeric
          return obj is not NaT and not isinstance(
              obj, (np.datetime64, np.timedelta64)
          )
      elif dtype.kind == "b":
          # We allow pd.NA, None, np.nan in BooleanArray (same as IntervalDtype)
          return (
              lib.is_float(obj) or obj is None or obj is libmissing.NA
          )
  
      elif dtype == _dtype_str:
          # numpy string dtypes to avoid float np.nan
          return not isinstance(
              obj, (np.datetime64, np.timedelta64, Decimal, float)
          )
  
      elif dtype == _dtype_object:
          # This is needed for Categorical, but is kind of weird
          return True
  
      elif isinstance(dtype, PeriodDtype):
          return not isinstance(
              obj, (np.datetime64, np.timedelta64, Decimal)
          )
  
      elif isinstance(dtype, IntervalDtype):
          return (
              lib.is_float(obj) or obj is None or obj is libmissing.NA
          )
  
      elif isinstance(dtype, CategoricalDtype):
          return is_valid_na_for_dtype(obj, dtype.categories.dtype)
  
      # fallback, default to allowing NaN, None, NA, NaT
      return not isinstance(
          obj, (np.datetime64, np.timedelta64, Decimal)
      )
  
imports: from __future__ import annotations
  from decimal import Decimal
  from functools import partial
  from typing import TYPE_CHECKING, overload
  import numpy
  from pandas._config import get_option
  from pandas._libs import lib
  import pandas._libs.missing
  from pandas._libs.tslibs import NaT, iNaT
  from pandas.core.dtypes.common import DT64NS_DTYPE, TD64NS_DTYPE, ensure_object, is_bool_dtype, is_categorical_dtype, is_complex_dtype, is_dtype_equal, is_extension_array_dtype, is_float_dtype, is_integer_dtype, is_object_dtype, is_scalar, is_string_or_object_np_dtype, needs_i8_conversion
  from pandas.core.dtypes.dtypes import CategoricalDtype, DatetimeTZDtype, ExtensionDtype, IntervalDtype, PeriodDtype
  from pandas.core.dtypes.generic import ABCDataFrame, ABCExtensionArray, ABCIndex, ABCMultiIndex, ABCSeries
  from pandas.core.dtypes.inference import is_list_like
label_desc: Use image node_id 27 for calling a global function with example usage: is_valid_na_for_dtype(obj, dtype) and returns: unknown, False, unknown, unknown, unknown, unknown, unknown, unknown, True, unknown, unknown, is_valid_na_for_dtype