code: def convert(path, mode, kernel_name=None, timeout=40 * 60):
      print(f"=== {path.name} ", end="")
      sys.stdout.flush()
  
      with path.open() as in_file:
          template = env.from_string(in_file.read())
  
      markdown = template.render(mode=mode)
      markdown = black_cells(markdown)
  
      start = time.time()
      output = run_notebook(
          markdown,
          kernel_name,
          timeout,
          execute=mode != "skip",
      )
      print(f"finished evaluation in {time.time() - start} sec")
  
      # XXX.md.input -> XXX.ipynb
      # `with_suffix` only operates on last suffix, so we need some more involved
      # logic.
      stem = path.name.split(".", 1)[0]
      with path.with_name(stem).with_suffix(".ipynb").open(
          "w"
      ) as outfile:
          outfile.write(output)
  
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 3 for calling a global function with example usage: convert(path, mode, kernel_name, timeout) without return types