code: def deep_reload_hook(m):
      """Replacement for reload()."""
      if not isinstance(m, ModuleType):
          raise TypeError("reload() argument must be module")
  
      name = m.__name__
  
      if name not in sys.modules:
          raise ImportError(
              "reload(): module %.200s not in sys.modules" % name
          )
  
      global modules_reloading
      try:
          return modules_reloading[name]
      except:
          modules_reloading[name] = m
  
      dot = name.rfind(".")
      if dot < 0:
          subname = name
          path = None
      else:
          try:
              parent = sys.modules[name[:dot]]
          except KeyError:
              modules_reloading.clear()
              raise ImportError(
                  "reload(): parent %.200s not in sys.modules"
                  % name[:dot]
              )
          subname = name[dot + 1 :]
          path = getattr(parent, "__path__", None)
  
      try:
          # This appears to be necessary on Python 3, because imp.find_module()
          # tries to import standard libraries (like io) itself, and we don't
          # want them to be processed by our deep_import_hook.
          with replace_import_hook(original_import):
              fp, filename, stuff = imp.find_module(subname, path)
      finally:
          modules_reloading.clear()
  
      try:
          newm = imp.load_module(name, fp, filename, stuff)
      except:
          # load_module probably removed name from modules because of
          # the error.  Put back the original module object.
          sys.modules[name] = m
          raise
      finally:
          if fp:
              fp.close()
  
      modules_reloading.clear()
      return newm
  
file_path: catboost/contrib/python/ipython/py2/IPython/lib/deepreload.py
imports: from __future__ import print_function
  from contextlib import contextmanager
  import imp
  import sys
  from types import ModuleType
  from warnings import warn
  from IPython.utils.py3compat import builtin_mod, builtin_mod_name
label_desc: Use image node_id 8 for calling a global function with example usage: deep_reload_hook(m) and returns: newm, modules_reloading