code: def _get_result_filter(args):
      from datalad.support.constraints import EnsureKeyChoice
  
      result_filter = None
      if (
          args.common_report_status
          or "datalad.runtime.report-status" in cfg
      ):
          report_status = args.common_report_status or cfg.obtain(
              "datalad.runtime.report-status"
          )
          if report_status == "all":
              pass  # no filter
          elif report_status == "success":
              result_filter = EnsureKeyChoice(
                  "status", ("ok", "notneeded")
              )
          elif report_status == "failure":
              result_filter = EnsureKeyChoice(
                  "status", ("impossible", "error")
              )
          else:
              result_filter = EnsureKeyChoice(
                  "status", (report_status,)
              )
      if args.common_report_type:
          tfilt = EnsureKeyChoice(
              "type", tuple(args.common_report_type)
          )
          result_filter = (
              result_filter & tfilt if result_filter else tfilt
          )
      return result_filter
  
imports: from datalad import cfg
  from datalad.interface.base import is_api_arg
  from datalad.utils import getargspec
label_desc: Use image node_id 2 for calling a global function with example usage: _get_result_filter(args) and returns: result_filter