code: def _process_results(
      results,
      cmd_class,
      on_failure,
      action_summary,
      incomplete_results,
      result_renderer,
      result_log_level,
      allkwargs,
  ):
      # private helper pf @eval_results
      # loop over results generated from some source and handle each
      # of them according to the requested behavior (logging, rendering, ...)
  
      # used to track repeated messages in the generic renderer
      last_result = None
      # the timestamp of the last renderer result
      last_result_ts = None
      # counter for detected repetitions
      last_result_reps = 0
      # how many repetitions to show, before suppression kicks in
      render_n_repetitions = (
          dlcfg.obtain("datalad.ui.suppress-similar-results-threshold")
          if sys.stdout.isatty()
          and dlcfg.obtain("datalad.ui.suppress-similar-results")
          else float("inf")
      )
  
      for res in results:
          if not res or "action" not in res:
              # XXX Yarik has to no clue on how to track the origin of the
              # record to figure out WTF, so he just skips it
              # but MIH thinks leaving a trace of that would be good
              lgr.debug('Drop result record without "action": %s', res)
              continue
  
          actsum = action_summary.get(res["action"], {})
          if res["status"]:
              actsum[res["status"]] = actsum.get(res["status"], 0) + 1
              action_summary[res["action"]] = actsum
          ## log message, if there is one and a logger was given
          msg = res.get("message", None)
          # remove logger instance from results, as it is no longer useful
          # after logging was done, it isn't serializable, and generally
          # pollutes the output
          res_lgr = res.pop("logger", None)
          if msg and res_lgr:
              if isinstance(res_lgr, logging.Logger):
                  # didn't get a particular log function, go with default
                  res_lgr = getattr(
                      res_lgr,
                      default_logchannels[res["status"]]
                      if result_log_level == "match-status"
                      else result_log_level,
                  )
              msg = res["message"]
              msgargs = None
              if isinstance(msg, tuple):
                  msgargs = msg[1:]
                  msg = msg[0]
              if "path" in res:
                  # result path could be a path instance
                  path = str(res["path"])
                  if msgargs:
                      # we will pass the msg for %-polation, so % should be doubled
                      path = path.replace("%", "%%")
                  msg = "{} [{}({})]".format(msg, res["action"], path)
              if msgargs:
                  # support string expansion of logging to avoid runtime cost
                  try:
                      res_lgr(msg, *msgargs)
                  except TypeError as exc:
                      raise TypeError(
                          "Failed to render %r with %r from %r: %s"
                          % (msg, msgargs, res, str(exc))
                      ) from exc
              else:
                  res_lgr(msg)
  
          ## output rendering
          if result_renderer is None or result_renderer == "disabled":
              pass
          elif result_renderer == "generic":
              (
                  last_result_reps,
                  last_result,
                  last_result_ts,
              ) = _render_result_generic(
                  res,
                  render_n_repetitions,
                  last_result_reps,
                  last_result,
                  last_result_ts,
              )
          elif result_renderer in ("json", "json_pp"):
              _render_result_json(res, result_renderer.endswith("_pp"))
          elif result_renderer == "tailored":
              cmd_class.custom_result_renderer(res, **allkwargs)
          elif hasattr(result_renderer, "__call__"):
              _render_result_customcall(res, result_renderer, allkwargs)
          else:
              raise ValueError(
                  f'unknown result renderer "{result_renderer}"'
              )
  
          ## error handling
          # looks for error status, and report at the end via
          # an exception
          if on_failure in ("continue", "stop") and res["status"] in (
              "impossible",
              "error",
          ):
              incomplete_results.append(res)
              if on_failure == "stop":
                  # first fail -> that's it
                  # raise will happen after the loop
                  break
          yield res
      # make sure to report on any issues that we had suppressed
      _display_suppressed_message(
          last_result_reps,
          render_n_repetitions,
          last_result_ts,
          final=True,
      )
  
imports: import logging
  import sys
  from time import time
  from os import listdir
  from os.path import join
  from os.path import isdir
  from os.path import relpath
  from os.path import sep
  import json
  from typing import TypeVar
  from datalad.utils import with_pathsep
  from datalad.utils import path_startswith, path_is_subpath, ensure_unicode, getargspec
  from datalad.support.gitrepo import GitRepo
  from datalad.support.exceptions import CapturedException
  from datalad import cfg
  from datalad.dochelpers import single_or_plural
  from datalad.ui import ui
  import datalad.support.ansi_colors
label_desc: Use image node_id 9 for calling a global function with example usage: _process_results(results, cmd_class, on_failure, action_summary, incomplete_results, result_renderer, result_log_level, allkwargs) without return types