code: def onnx_documentation_folder(
      folder, title="ONNX Operators", flog=None, max_opsets=None
  ):
      """
      Creates documentation in a folder for all known
      ONNX operators or a subset.
      :param folder: folder where to write the documentation
      :param title: index title
      :param flog: logging function
      :param max_opsets: included operator definition up to this opsets
      :return: list of creates files
      """
  
      class _Table:
          def __init__(self, ops, domain, title=None):
              self.title = title or domain
              self.domain = domain
              self.ops = ops
  
          @property
          def domain_name(self):
              title = self.domain
              if title == "":
                  title = "ai.onnx"
              return title
  
          def render(self, indent=""):
              table_dom = [""]
              table_dom.extend(
                  [
                      ".. list-table::",
                      "    :widths: 10 10 10",
                      "    :header-rows: 1",
                      "",
                      "    * - operator",
                      "      - versions",
                      "      - differences",
                  ]
              )
  
              for op in self.ops:
                  name = op["name"]
                  dom = self.domain.replace(".", "-")
                  table_dom.append(
                      f"    * - :ref:`{name} <l-onnx-doc{dom}-{name}>`"
                  )
                  versions = sorted(
                      [
                          (k, v)
                          for k, v in op["links"].items()
                          if isinstance(k, int)
                      ],
                      reverse=True,
                  )
                  col1 = ", ".join(
                      f":ref:`{k} <{v}>`" for k, v in versions
                  )
                  diffs = sorted(
                      [
                          (k, v)
                          for k, v in op["links"].items()
                          if isinstance(k, tuple)
                      ],
                      reverse=True,
                  )
                  col2 = ", ".join(
                      f":ref:`{k[1]}/{k[0]} <{v}>`" for k, v in diffs
                  )
                  table_dom.append(f"      - {col1}")
                  table_dom.append(f"      - {col2}")
              table_dom.append("")
              if indent != "":
                  for i in range(len(table_dom)):
                      table_dom[i] = indent + table_dom[i]
              res = "\n".join(table_dom)
              return res
  
      all_schemas_available = _get_all_schemas_with_history()
      if len(all_schemas_available) < 3:
          raise RuntimeError(
              f"At least three domains are expected, found {list(all_schemas_available)}."
          )
  
      # filter out operator under development
      all_schemas = {}
      for domain, opset in all_schemas_available.items():
          max_version = (
              None
              if max_opsets is None
              else max_opsets.get(domain, None)
          )
          d = {}
          for op, schemas in opset.items():
              vers = {}
              for version, schema in schemas.items():
                  if max_version is not None and version > max_version:
                      continue
                  vers[version] = schema
              d[op] = vers
          all_schemas[domain] = d
  
      if len(all_schemas) < 3:
          raise RuntimeError(
              f"At leat three domains are expected, found {list(all_schemas)} in all_schemas."
          )
  
      if not os.path.exists(folder):
          os.makedirs(folder)
  
      pages = []
      tables = []
  
      # loop on domains
      for dom in sorted(all_schemas):
          sdom = "ai.onnx" if dom == "" else dom
          dom_pages = []
  
          do = all_schemas[dom]
          if len(do) == 0:
              raise RuntimeError(f"No operator for domain={dom!r}.")
  
          # loop on operators
          for op in sorted(do):
              if flog is not None:
                  flog(f"generate page for onnx {dom!r} - {op!r}")
              page_name = f"onnx_{dom.replace('.', '')}_{op}"
              doc, d_links, n_examples = get_markdown_doc(
                  folder,
                  op,
                  domain=dom,
                  version=None,
                  example=True,
                  diff=True,
              )
              if flog is not None and n_examples == 0:
                  flog(
                      f"{' '* 14}no_example for {op} from domain {domain}"
                  )
              if dom == "":
                  main = op
              else:
                  main = f"{dom} - {op}"
              sdom = dom.replace(".", "-")
              # Target in MyST https://myst-parser.readthedocs.io/en/v0.15.1/syntax/syntax.html?highlight=role#extra-markdown-syntax
              ref_link = f"(l-onnx-doc{sdom}-{op})="
              rows = [
                  "",
                  ref_link,
                  "",
                  f"# {main}",
                  "",
                  doc,
              ]
  
              full = os.path.join(folder, page_name + ".md")
              content = "\n".join(rows)
              pathlib.Path(full).write_text(content, encoding="utf-8")
              pages.append(full)
              dom_pages.append({"name": op, "links": d_links})
  
          tables.append(_Table(dom_pages, dom, sdom))
  
      # final
      if len(tables) < 3:
          raise RuntimeError(
              f"At least three domain are expected not {len(tables)}."
          )
      index = _template_main.render(
          pages=pages, tabs=tables, os=os, len=len, title=title
      )
      index = _clean_unicode(index)
      page_name = os.path.join(folder, "index.rst")
      pathlib.Path(page_name).write_text(index, encoding="utf-8")
      pages.append(page_name)
      return pages
  
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 14 for calling a global function with example usage: onnx_documentation_folder(folder, title, flog, max_opsets) and returns: pages, title, res