code: def black_cells(text):
      CODE_RE = r"```py(?:thon)?\s*\n(.*?)```"
  
      text = re.sub(r"^%", r"# %-% #", text, flags=re.M)
  
      def apply_black(match):
          code = match.group(1)
  
          formatted = black.format_str(code, mode=black.Mode())
  
          return "\n".join(["```", formatted.rstrip(), "```"])
  
      formatted = re.sub(CODE_RE, apply_black, text, flags=re.S)
      return re.sub(r"^# %-% #", r"%", formatted, flags=re.M)
  
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 2 for calling a global function with example usage: black_cells(text) and returns: re, str