code: def getdoc(obj):
      """Stable wrapper around inspect.getdoc.
  
      This can't crash because of attribute problems.
  
      It also attempts to call a getdoc() method on the given object.  This
      allows objects which provide their docstrings via non-standard mechanisms
      (like Pyro proxies) to still be inspected by ipython's ? system.
      """
      # Allow objects to offer customized documentation via a getdoc method:
      try:
          ds = obj.getdoc()
      except Exception:
          pass
      else:
          # if we get extra info, we add it to the normal docstring.
          if isinstance(ds, string_types):
              return inspect.cleandoc(ds)
      try:
          docstr = inspect.getdoc(obj)
          encoding = get_encoding(obj)
          return py3compat.cast_unicode(docstr, encoding=encoding)
      except Exception:
          # Harden against an inspect failure, which can occur with
          # extensions modules.
          raise
          return None
  
imports: from __future__ import print_function
  import inspect
  import linecache
  import warnings
  import os
  from textwrap import dedent
  import types
  import io
  from IPython.core import page
  from IPython.lib.pretty import pretty
  from IPython.testing.skipdoctest import skip_doctest_py3
  from IPython.utils import PyColorize
  from IPython.utils import openpy
  from IPython.utils import py3compat
  from IPython.utils.dir2 import safe_hasattr
  from IPython.utils.path import compress_user
  from IPython.utils.text import indent
  from IPython.utils.wildcard import list_namespace
  from IPython.utils.coloransi import TermColors, ColorScheme, ColorSchemeTable
  from IPython.utils.py3compat import cast_unicode, string_types, PY3
  from IPython.utils.signatures import signature
  from IPython.utils.colorable import Colorable
  from pygments import highlight
  from pygments.formatters import HtmlFormatter
label_desc: Use image node_id 4 for calling a global function with example usage: getdoc(obj) and returns: py3compat, inspect, None