code: def get_func_code(func):
      """Attempts to retrieve a reliable function code hash.
  
      The reason we don't use inspect.getsource is that it caches the
      source, whereas we want this to be modified on the fly when the
      function is modified.
  
      Returns
      -------
      func_code: string
          The function code
      source_file: string
          The path to the file in which the function is defined.
      first_line: int
          The first line of the code in the source file.
  
      Notes
      ------
      This function does a bit more magic than inspect, and is thus
      more robust.
      """
      source_file = None
      try:
          code = func.__code__
          source_file = code.co_filename
          if not os.path.exists(source_file):
              # Use inspect for lambda functions and functions defined in an
              # interactive shell, or in doctests
              source_code = "".join(inspect.getsourcelines(func)[0])
              line_no = 1
              if source_file.startswith("<doctest "):
                  source_file, line_no = re.match(
                      "\<doctest (.*\.rst)\[(.*)\]\>", source_file
                  ).groups()
                  line_no = int(line_no)
                  source_file = "<doctest %s>" % source_file
              return source_code, source_file, line_no
          # Try to retrieve the source code.
          with open_py_source(source_file) as source_file_obj:
              first_line = code.co_firstlineno
              # All the lines after the function definition:
              source_lines = list(
                  islice(source_file_obj, first_line - 1, None)
              )
          return (
              "".join(inspect.getblock(source_lines)),
              source_file,
              first_line,
          )
      except:
          # If the source code fails, we use the hash. This is fragile and
          # might change from one session to another.
          if hasattr(func, "__code__"):
              # Python 3.X
              return str(func.__code__.__hash__()), source_file, -1
          else:
              # Weird objects like numpy ufunc don't have __code__
              # This is fragile, as quite often the id of the object is
              # in the repr, so it might not persist across sessions,
              # however it will work for ufuncs.
              return repr(func), source_file, -1
  
file_path: catboost/contrib/python/scikit-learn/py2/sklearn/externals/joblib/func_inspect.py
imports: from itertools import islice
  import inspect
  import warnings
  import re
  import os
  from ._compat import _basestring
  from .logger import pformat
  from ._memory_helpers import open_py_source
  from ._compat import PY3_OR_LATER
label_desc: Use image node_id 1 for calling a global function with example usage: get_func_code(func) and returns: str,  source_file,  first_line, source_code,  source_file,  line_no, str,  source_file,  unknown, repr,  source_file,  unknown