code: def run_notebook(text, kernel_name, timeout, execute) -> str:
      # We add two blank lines at the end to ensure
      # that the final cell also runs.
      text += "\n" * 2
      notebook = notedown.MarkdownReader().reads(text)
  
      if execute:
          kwargs = {}
          if kernel_name is not None:
              kwargs["kernel_name"] = kernel_name
  
          client = NotebookClient(
              notebook,
              timeout=timeout,
              resources={"metadata": {"path": "."}},
              **kwargs,
          )
          client.execute()
  
      # need to add language info to for syntax highlight
      notebook["metadata"].update(language_info={"name": "python"})
  
      return nbformat.writes(notebook)
  
file_path: gluonts/docs/md2ipynb.py
imports: import re
  import sys
  import time
  from pathlib import Path
  import black
  import click
  import nbformat
  import notedown
  from nbclient import NotebookClient
  from jinja2 import Environment
label_desc: Use image node_id 1 for calling a global function with example usage: run_notebook(text, kernel_name, timeout, execute) and returns: nbformat