code: def _insert_diff(
      folder,
      docs,
      split=".. tag-diff-insert.",
      op_name=None,
      version=None,
      domain=None,
  ):
      """
      Splits a using `split`, insert HTML differences between pieces.
      The function relies on package `pyquickhelper`.
      """
      doc_parts = docs.split(split)
      if len(doc_parts) <= 1:
          return docs
  
      reg = re.compile("([A-Z][A-Za-z0-9_]*) - ([0-9]+)")
  
      d_links = {}
      pieces = [doc_parts[0]]
      mds = []
      for i in range(1, len(doc_parts)):
          spl1 = doc_parts[i - 1].strip("\n ")
          spl2 = doc_parts[i].strip("\n ")
          vers1 = reg.findall(spl1)
          vers2 = reg.findall(spl2)
  
          spl1 = spl1.split("### Examples")[0].replace("`", "")
          spl2 = spl2.split("### Examples")[0].replace("`", "")
          spl1 = spl1.split("### Summary")[-1].strip("\n ")
          spl2 = spl2.split("### Summary")[-1].strip("\n ")
          if len(spl1) < 5 or len(spl2) < 5:
              pieces.append(doc_parts[i])
              continue
          if not vers1:
              raise ValueError(
                  f"Unable to find version {version!r} in\n{spl1}"
              )
          if not vers2:
              raise ValueError(
                  f"Unable to find version {version!r} in\n{spl2}"
              )
          v2 = vers2[0][1]
          v1 = vers1[0][1]
  
          if not mds:
              mds.append(
                  (
                      v1,
                      textwrap.dedent(spl1.strip(" \n\r\t")).splitlines(
                          keepends=True
                      ),
                  )
              )
          mds.append(
              (
                  v2,
                  textwrap.dedent(spl2.strip(" \n\r\t")).splitlines(
                      keepends=True
                  ),
              )
          )
  
          if len(mds) > 1:
              show_diff_toc = True
          else:
              show_diff_toc = False
  
          if show_diff_toc:
              pieces.append("```{toctree}")
  
          for di in range(len(mds) - 1):
              dj = len(mds) - 1
  
              v1, s1 = mds[di]
              v2, s2 = mds[dj]
              differ = difflib.Differ()
              result = list(differ.compare(s2, s1))
              raw = "".join(result)
  
              diff = _template_diff.render(
                  op_name=op_name,
                  version1=v2,
                  version2=v1,
                  div_name=f"div_{op_name}_{i}",
                  diff_content=raw,
              )
              diff = _clean_unicode(diff)
  
              title = f"{op_name} - {v2} vs {v1}"
  
              name = f"text_diff_{op_name}_{v2}_{v1}"
              domain_str = domain.replace(".", "-")
              link = (
                  f"l-onnx-op{domain_str}-{op_name.lower()}-d{v2}-{v1}"
              )
              d_links[int(v2), int(v1)] = link
              content = "\n".join(
                  [
                      "",
                      f".. _{link}:",
                      "",
                      title,
                      "=" * len(title),
                      "",
                      "Next section compares an older to a newer version of the same operator ",
                      "after both definition are converted into markdown text.",
                      "Green means an addition to the newer version, red means a deletion.",
                      "Anything else is unchanged.",
                      "",
                      ".. raw:: html",
                      "",
                      textwrap.indent(diff, "    "),
                  ]
              )
              filename = os.path.join(folder, name + ".rst")
              pathlib.Path(filename).write_text(
                  content, encoding="utf-8"
              )
              # Add diff page to the toctree using myst syntax
              pieces.append(name)
  
          if show_diff_toc:
              # End the toctree
              pieces.append("```")
  
          pieces.extend(["", doc_parts[i]])
  
      return "\n".join(pieces), d_links
  
imports: import difflib
  import importlib
  import inspect
  import keyword
  import os
  import pathlib
  import re
  import shutil
  import sys
  import textwrap
  from typing import Any
  import jinja2
  import numpy
  from sphinx.util import logging
  import onnx
  from onnx.backend.test.case.base import _Exporter
  from onnx.defs import OpSchema
label_desc: Use image node_id 9 for calling a global function with example usage: _insert_diff(folder, docs, split, op_name, version, domain) and returns: str,  d_links, docs