code: def wrap_displaymath(
      text: str, label: str | None, numbering: bool
  ) -> str:
      def is_equation(part: str) -> str:
          return part.strip()
  
      if label is None:
          labeldef = ""
      else:
          labeldef = r"\label{%s}" % label
          numbering = True
  
      parts = list(filter(is_equation, text.split("\n\n")))
      equations = []
      if len(parts) == 0:
          return ""
      elif len(parts) == 1:
          if numbering:
              begin = r"\begin{equation}" + labeldef
              end = r"\end{equation}"
          else:
              begin = r"\begin{equation*}" + labeldef
              end = r"\end{equation*}"
          equations.append("\\begin{split}%s\\end{split}\n" % parts[0])
      else:
          if numbering:
              begin = r"\begin{align}%s\!\begin{aligned}" % labeldef
              end = r"\end{aligned}\end{align}"
          else:
              begin = r"\begin{align*}%s\!\begin{aligned}" % labeldef
              end = r"\end{aligned}\end{align*}"
          for part in parts:
              equations.append("%s\\\\\n" % part.strip())
  
      concatenated_equations = "".join(equations)
      return f"{begin}\n{concatenated_equations}{end}"
  
imports: from __future__ import annotations
  from typing import TYPE_CHECKING
label_desc: Use image node_id 2 for calling a global function with example usage: wrap_displaymath(text, label, numbering) and returns: begin, str, concatenated_equations, end, part, str