code: def _safe_is_pandas_categorical_dtype(dt):
      if PD_LT_2:
          return pd.api.types.is_categorical_dtype(dt)
      return isinstance(dt, pd.CategoricalDtype)
  
imports: from statsmodels.compat.pandas import PD_LT_2
  import pandas
  import patsy.util
label_desc: Use image node_id 1 for calling a global function with example usage: _safe_is_pandas_categorical_dtype(dt) and returns: isinstance, pd