code: def display_plot_ipython(
      viz: Network,
      output_filename: str,
      layout_kwargs: Dict[str, Dict] = None,
  ) -> IFrame:
      """
      Displays a PyVis object using ipython.
      Args:
          viz: pyvis object to render.
          output_filename: write html to a given path, e.g. "./plot.html". File as to end in ".html"
          layout_kwargs: Dictionary to set the `layout` and `physics` of the graph.
              Example:
              ::
                  >>> layout_kwargs = {
                          "physics": {
                              "solver": "repulsion"
                              },
                          "layout": {
                              "hierarchical": {
                                  "enabled": True
                                  }
                              }
                          }
      Returns:
          IPython IFrame object. Renders in a notebook.
      Raises:
          ImportError: if IPython is not installed (optional dependency).
      """
      layout_kwargs = layout_kwargs or {}
      viz.set_options(options=json.dumps(layout_kwargs))
  
      html = viz.generate_html()
  
      with open(output_filename, mode="w", encoding="UTF-8") as f:
          f.write(html)
  
      return IFrame(
          src=output_filename,
          width=viz.width,
          height=viz.height,
          extras=[
              f"srcdoc='{escape(viz.generate_html(notebook=False))}'"
          ],
      )
  
imports: import json
  from html import escape
  from typing import Dict
  from IPython.lib.display import IFrame
  from pyvis.network import Network
label_desc: Use image node_id 1 for calling a global function with example usage: display_plot_ipython(viz, output_filename, layout_kwargs) and returns: IFrame