code: def eval_results(wrapped):
      """Decorator for return value evaluation of datalad commands.
  
      Note, this decorator is only compatible with commands that return
      status dict sequences!
  
      Two basic modes of operation are supported: 1) "generator mode" that
      `yields` individual results, and 2) "list mode" that returns a sequence of
      results. The behavior can be selected via the kwarg `return_type`.
      Default is "list mode".
  
      This decorator implements common functionality for result rendering/output,
      error detection/handling, and logging.
  
      Result rendering/output configured via the `result_renderer` keyword
      argument of each decorated command. Supported modes are: 'generic' (a
      generic renderer producing one line per result with key info like action,
      status, path, and an optional message); 'json' (a complete JSON line
      serialization of the full result record), 'json_pp' (like 'json', but
      pretty-printed spanning multiple lines), 'tailored' custom output
      formatting provided by each command class (if any), or 'disabled' for
      no result rendering.
  
      Error detection works by inspecting the `status` item of all result
      dictionaries. Any occurrence of a status other than 'ok' or 'notneeded'
      will cause an IncompleteResultsError exception to be raised that carries
      the failed actions' status dictionaries in its `failed` attribute.
  
      Status messages will be logged automatically, by default the following
      association of result status and log channel will be used: 'ok' (debug),
      'notneeded' (debug), 'impossible' (warning), 'error' (error).  Logger
      instances included in the results are used to capture the origin of a
      status report.
  
      Parameters
      ----------
      func: function
        __call__ method of a subclass of Interface,
        i.e. a datalad command definition
      """
  
      @wraps(wrapped)
      def eval_func(*args, **kwargs):
          lgr.log(2, "Entered eval_func for %s", wrapped)
          # determine the command class associated with `wrapped`
          wrapped_class = get_wrapped_class(wrapped)
  
          # retrieve common options from kwargs, and fall back on the command
          # class attributes, or general defaults if needed
          kwargs = (
              kwargs.copy()
          )  # we will pop, which might cause side-effect
          common_params = {
              p_name: kwargs.pop(
                  # go with any explicitly given default
                  p_name,
                  # otherwise determine the command class and pull any
                  # default set in that class
                  getattr(wrapped_class, p_name),
              )
              for p_name in eval_params
          }
  
          # short cuts and configured setup for common options
          return_type = common_params["return_type"]
  
          if return_type == "generator":
              # hand over the generator
              lgr.log(
                  2,
                  "Returning generator_func from eval_func for %s",
                  wrapped_class,
              )
              return _execute_command_(
                  interface=wrapped_class,
                  cmd=wrapped,
                  cmd_args=args,
                  cmd_kwargs=kwargs,
                  exec_kwargs=common_params,
              )
          else:
  
              @wraps(_execute_command_)
              def return_func(*args_, **kwargs_):
                  results = _execute_command_(
                      interface=wrapped_class,
                      cmd=wrapped,
                      cmd_args=args,
                      cmd_kwargs=kwargs,
                      exec_kwargs=common_params,
                  )
                  if inspect.isgenerator(results):
                      # unwind generator if there is one, this actually runs
                      # any processing
                      results = list(results)
                  if return_type == "item-or-list" and len(results) < 2:
                      return results[0] if results else None
                  else:
                      return results
  
              lgr.log(
                  2,
                  "Returning return_func from eval_func for %s",
                  wrapped_class,
              )
              return return_func(*args, **kwargs)
  
      ret = eval_func
      ret._eval_results = True
      return ret
  
imports: import inspect
  import logging
  import os
  import re
  import textwrap
  import warnings
  from abc import ABC, abstractmethod
  from functools import wraps
  from importlib import import_module
  from typing import Callable, Dict, Generator, TypeVar, TYPE_CHECKING
  import datalad
  from datalad import cfg
  from datalad.core.local.resulthooks import get_jsonhooks_from_config, match_jsonhook2result, run_jsonhook
  from datalad.distribution.dataset import Dataset, resolve_path
  from datalad.interface.common_opts import eval_params
  from datalad.interface.results import known_result_xfms
  from datalad.interface.utils import get_result_filter, keep_result, render_action_summary, xfm_result, _process_results
  from datalad.support.exceptions import CapturedException, IncompleteResultsError
  from datalad.utils import get_wrapped_class
label_desc: Use image node_id 15 for calling a global function with example usage: eval_results(wrapped) and returns: ret, _execute_command_, return_func, unknown, results