code: def run(self):
      debug = False
  
      # TODO, any reason block_parser can't be a method of embeddable shell
      # then we wouldn't have to carry these around
      rgxin, rgxout, promptin, promptout = self.setup()
  
      options = self.options
      self.shell.is_suppress = "suppress" in options
      self.shell.is_doctest = "doctest" in options
      self.shell.is_verbatim = "verbatim" in options
      self.shell.is_okexcept = "okexcept" in options
      self.shell.is_okwarning = "okwarning" in options
  
      # handle pure python code
      if "python" in self.arguments:
          content = self.content
          self.content = self.shell.process_pure_python(content)
  
      # parts consists of all text within the ipython-block.
      # Each part is an input/output block.
      parts = "\n".join(self.content).split("\n\n")
  
      lines = [".. code-block:: ipython", ""]
      figures = []
  
      for part in parts:
          block = block_parser(part, rgxin, rgxout, promptin, promptout)
          if len(block):
              rows, figure = self.shell.process_block(block)
              for row in rows:
                  lines.extend(
                      [
                          "   {0}".format(line)
                          for line in row.split("\n")
                      ]
                  )
  
              if figure is not None:
                  figures.append(figure)
  
      for figure in figures:
          lines.append("")
          lines.extend(figure.split("\n"))
          lines.append("")
  
      if len(lines) > 2:
          if debug:
              print("\n".join(lines))
          else:
              # This has to do with input, not output. But if we comment
              # these lines out, then no IPython code will appear in the
              # final output.
              self.state_machine.insert_input(
                  lines, self.state_machine.input_lines.source(0)
              )
  
      # cleanup
      self.teardown()
  
      return []
  
imports: from __future__ import print_function
  import atexit
  import errno
  import os
  import re
  import sys
  import tempfile
  import ast
  import warnings
  import shutil
  from docutils.parsers.rst import directives
  from docutils.parsers.rst import Directive
  from traitlets.config import Config
  from IPython import InteractiveShell
  from IPython.core.profiledir import ProfileDir
  from IPython.utils import io
  from IPython.utils.py3compat import PY3
label_desc: Use image node_id 4 for calling the IPythonDirective obj's underlying member method code with example usage: obj.run() and returns: list