docstr: %autoreload => Reload modules automatically
  
  %autoreload or %autoreload now
  Reload all modules (except those excluded by %aimport) automatically
  now.
  
  %autoreload 0 or %autoreload off
  Disable automatic reloading.
  
  %autoreload 1 or %autoreload explicit
  Reload only modules imported with %aimport every time before executing
  the Python code typed.
  
  %autoreload 2 or %autoreload all
  Reload all modules (except those excluded by %aimport) every time
  before executing the Python code typed.
  
  %autoreload 3 or %autoreload complete
  Same as 2/all, but also but also adds any new objects in the module. See
  unit test at IPython/extensions/tests/test_autoreload.py::test_autoload_newly_added_objects
  
  The optional arguments --print and --log control display of autoreload activity. The default
  is to act silently; --print (or -p) will print out the names of modules that are being
  reloaded, and --log (or -l) outputs them to the log at INFO level.
  
  The optional argument --hide-errors hides any errors that can happen when trying to
  reload code.
  
  Reloading Python modules in a reliable way is in general
  difficult, and unexpected things may occur. %autoreload tries to
  work around common pitfalls by replacing function code objects and
  parts of classes previously in the module with new versions. This
  makes the following things to work:
  
  - Functions and classes imported via 'from xxx import foo' are upgraded
    to new versions when 'xxx' is reloaded.
  
  - Methods and properties of classes are upgraded on reload, so that
    calling 'c.foo()' on an object 'c' created before the reload causes
    the new code for 'foo' to be executed.
  
  Some of the known remaining caveats are:
  
  - Replacing code objects does not always succeed: changing a @property
    in a class to an ordinary method or a method to a member variable
    can cause problems (but in old objects only).
  
  - Functions that are removed (eg. via monkey-patching) from a module
    before it is reloaded are not upgraded.
  
  - C extension modules cannot be reloaded, and so cannot be
    autoreloaded.
docstr_tok: ["%","autoreload","=",">","Reload","modules","automatically","%","autoreload","or","%","autoreload","now","Reload","all","modules","(","except","those","excluded","by","%","aimport",")","automatically","now",".","%","autoreload","0","or","%","autoreload","off","Disable","automatic","reloading",".","%","autoreload","1","or","%","autoreload","explicit","Reload","only","modules","imported","with","%","aimport","every","time","before","executing","the","Python","code","typed",".","%","autoreload","2","or","%","autoreload","all","Reload","all","modules","(","except","those","excluded","by","%","aimport",")","every","time","before","executing","the","Python","code","typed",".","%","autoreload","3","or","%","autoreload","complete","Same","as","2\/all",",","but","also","but","also","adds","any","new","objects","in","the","module",".","See","unit","test","at","IPython\/extensions\/tests\/test_autoreload.py",":",":test_autoload_newly_added_objects","The","optional","arguments","--","print","and","--","log","control","display","of","autoreload","activity",".","The","default","is","to","act","silently",";","--","print","(","or","-p",")","will","print","out","the","names","of","modules","that","are","being","reloaded",",","and","--","log","(","or","-l",")","outputs","them","to","the","log","at","INFO","level",".","The","optional","argument","--","hide-errors","hides","any","errors","that","can","happen","when","trying","to","reload","code",".","Reloading","Python","modules","in","a","reliable","way","is","in","general","difficult",",","and","unexpected","things","may","occur",".","%","autoreload","tries","to","work","around","common","pitfalls","by","replacing","function","code","objects","and","parts","of","classes","previously","in","the","module","with","new","versions",".","This","makes","the","following","things","to","work",":","-","Functions","and","classes","imported","via","'from","xxx","import","foo","'","are","upgraded","to","new","versions","when","'xxx","'","is","reloaded",".","-","Methods","and","properties","of","classes","are","upgraded","on","reload",",","so","that","calling","'","c.foo","(",")","'","on","an","object","'","c","'","created","before","the","reload","causes","the","new","code","for","'foo","'","to","be","executed",".","Some","of","the","known","remaining","caveats","are",":","-","Replacing","code","objects","does","not","always","succeed",":","changing","a","@","property","in","a","class","to","an","ordinary","method","or","a","method","to","a","member","variable","can","cause","problems","(","but","in","old","objects","only",")",".","-","Functions","that","are","removed","(","eg",".","via","monkey-patching",")","from","a","module","before","it","is","reloaded","are","not","upgraded",".","-","C","extension","modules","can","not","be","reloaded",",","and","so","can","not","be","autoreloaded","."]
code: def autoreload(self, line=""):
      r"""%autoreload => Reload modules automatically
  
      %autoreload or %autoreload now
      Reload all modules (except those excluded by %aimport) automatically
      now.
  
      %autoreload 0 or %autoreload off
      Disable automatic reloading.
  
      %autoreload 1 or %autoreload explicit
      Reload only modules imported with %aimport every time before executing
      the Python code typed.
  
      %autoreload 2 or %autoreload all
      Reload all modules (except those excluded by %aimport) every time
      before executing the Python code typed.
  
      %autoreload 3 or %autoreload complete
      Same as 2/all, but also but also adds any new objects in the module. See
      unit test at IPython/extensions/tests/test_autoreload.py::test_autoload_newly_added_objects
  
      The optional arguments --print and --log control display of autoreload activity. The default
      is to act silently; --print (or -p) will print out the names of modules that are being
      reloaded, and --log (or -l) outputs them to the log at INFO level.
  
      The optional argument --hide-errors hides any errors that can happen when trying to
      reload code.
  
      Reloading Python modules in a reliable way is in general
      difficult, and unexpected things may occur. %autoreload tries to
      work around common pitfalls by replacing function code objects and
      parts of classes previously in the module with new versions. This
      makes the following things to work:
  
      - Functions and classes imported via 'from xxx import foo' are upgraded
        to new versions when 'xxx' is reloaded.
  
      - Methods and properties of classes are upgraded on reload, so that
        calling 'c.foo()' on an object 'c' created before the reload causes
        the new code for 'foo' to be executed.
  
      Some of the known remaining caveats are:
  
      - Replacing code objects does not always succeed: changing a @property
        in a class to an ordinary method or a method to a member variable
        can cause problems (but in old objects only).
  
      - Functions that are removed (eg. via monkey-patching) from a module
        before it is reloaded are not upgraded.
  
      - C extension modules cannot be reloaded, and so cannot be
        autoreloaded.
  
      """
      args = magic_arguments.parse_argstring(self.autoreload, line)
      mode = args.mode.lower()
  
      p = print
  
      logger = logging.getLogger("autoreload")
  
      l = logger.info
  
      def pl(msg):
          p(msg)
          l(msg)
  
      if args.print is False and args.log is False:
          self._reloader._report = lambda msg: None
      elif args.print is True:
          if args.log is True:
              self._reloader._report = pl
          else:
              self._reloader._report = p
      elif args.log is True:
          self._reloader._report = l
  
      self._reloader.hide_errors = args.hide_errors
  
      if mode == "" or mode == "now":
          self._reloader.check(True)
      elif mode == "0" or mode == "off":
          self._reloader.enabled = False
      elif mode == "1" or mode == "explicit":
          self._reloader.enabled = True
          self._reloader.check_all = False
          self._reloader.autoload_obj = False
      elif mode == "2" or mode == "all":
          self._reloader.enabled = True
          self._reloader.check_all = True
          self._reloader.autoload_obj = False
      elif mode == "3" or mode == "complete":
          self._reloader.enabled = True
          self._reloader.check_all = True
          self._reloader.autoload_obj = True
      else:
          raise ValueError(f'Unrecognized autoreload mode "{mode}".')
  
imports: from IPython.core import magic_arguments
  from IPython.core.magic import Magics, magics_class, line_magic
  import os
  import sys
  import traceback
  import types
  import weakref
  import gc
  import logging
  from importlib import import_module, reload
  from importlib.util import source_from_cache
label_desc: Use image node_id 2 for calling the AutoreloadMagics obj's underlying member method code with example usage: obj.autoreload(line) without return types