code: def do_history(
      self,
      hist_access_type,
      output,
      raw,
      session=0,
      start=0,
      stop=None,
      n=None,
      pattern=None,
      unique=False,
  ):
      if hist_access_type == "tail":
          hist = self.shell.history_manager.get_tail(
              n, raw=raw, output=output, include_latest=True
          )
  
      elif hist_access_type == "range":
          hist = self.shell.history_manager.get_range(
              session, start, stop, raw=raw, output=output
          )
  
      elif hist_access_type == "search":
          hist = self.shell.history_manager.search(
              pattern, raw=raw, output=output, n=n, unique=unique
          )
      else:
          hist = []
  
      return {
          "status": "ok",
          "history": list(hist),
      }
  
imports: import getpass
  import sys
  from IPython.core import release
  from ipython_genutils.py3compat import builtin_mod, PY3, unicode_type, safe_unicode
  from IPython.utils.tokenutil import token_at_cursor, line_at_cursor
  from traitlets import Instance, Type, Any, List, Bool
  from .comm import CommManager
  from .kernelbase import Kernel
  from .zmqshell import ZMQInteractiveShell
label_desc: Use image node_id 17 for calling the IPythonKernel obj's underlying member method code with example usage: obj.do_history(hist_access_type, output, raw, session, start, stop, n, pattern, unique) and returns: dict