code: def _render_report(res):
      report = "# WTF"
      if not (res.get("status") == "ok" and "infos" in res):
          # some other record not intended to be rendered
          return
  
      def _unwind(text, val, top):
          if isinstance(val, dict):
              for k in sorted(val):
                  text += "\n{}{} {}{} ".format(
                      "##" if not top else top,
                      "-" if top else "",
                      k,
                      ":" if top else "",
                  )
                  text = _unwind(text, val[k], "{}  ".format(top))
          elif isinstance(val, (list, tuple)):
              for i, v in enumerate(val):
                  text += "\n{}{} ".format(top, "-")
                  text = _unwind(text, v, "{}  ".format(top))
          else:
              text += "{}".format(val)
          return text
  
      def _unwind_short(text, val, top):
          if isinstance(val, dict):
              if not top:
                  text += "\n"
                  for k, v in val.items():
                      text += (
                          "- " + _unwind_short(k, v, top + " ") + "\n"
                      )
              else:
                  text += ": " + " ".join(
                      "%s=%s" % i for i in val.items()
                  )
          elif isinstance(val, (list, tuple)):
              text += (" " if not top else "\n").join(map(str, val))
          else:
              text += "{}".format(val)
          return text
  
      unwinder = {"full": _unwind, "short": _unwind_short}[
          res.get("flavor", "full")
      ]
      report = unwinder(report, res.get("infos", {}), "")
      decor = res.get("decor", None)
  
      if not decor:
          return report
  
      if decor == "html_details":
          report = """\
  <details><summary>DataLad %s WTF (%s)</summary>
  
  %s
  </details>
          """ % (
              __version__,
              ", ".join(res.get("infos", {})),
              report,
          )
      else:
          raise ValueError("Unknown value of decor=%s" % decor)
      return report
  
imports: import logging
  import os
  import os.path
  import sys
  import tempfile
  import textwrap
  from collections import defaultdict
  from functools import partial
  from datalad.dochelpers import get_docstring_split
  from datalad.interface.base import Interface, build_doc
  from datalad.utils import ensure_unicode, getpwd, unlink, Path
  from datalad.support.external_versions import external_versions
  from datalad.support.exceptions import CapturedException, CommandError, InvalidGitRepositoryError
  from datalad import __version__
label_desc: Use image node_id 17 for calling a global function with example usage: _render_report(res) and returns: report, text, text, report