code: def safe_is_pandas_categorical(data):
      if not have_pandas_categorical:
          return False
      if isinstance(data, pandas.Categorical):
          return True
      if hasattr(data, "dtype"):
          return safe_is_pandas_categorical_dtype(data.dtype)
      return False
  
imports: import sys
  import numpy
  import six
  from six.moves import cStringIO
  from .compat import optional_dep_ok
label_desc: Use image node_id 29 for calling a global function with example usage: safe_is_pandas_categorical(data) and returns: False, False, True, safe_is_pandas_categorical_dtype