code: def get_status_dict(
      action: Optional[str] = None,
      ds: Optional[Dataset] = None,
      path: Optional[str] = None,
      type: Optional[str] = None,
      logger: Optional[logging.Logger] = None,
      refds: Optional[str] = None,
      status: Optional[str] = None,
      message: str | tuple | None = None,
      exception: Exception | CapturedException | None = None,
      error_message: str | tuple | None = None,
      **kwargs: Any,
  ) -> dict[str, Any]:
      # `type` is intentionally not `type_` or something else, as a mismatch
      # with the dict key 'type' causes too much pain all over the place
      # just for not shadowing the builtin `type` in this function
      """Helper to create a result dictionary.
  
      Most arguments match their key in the resulting dict, and their given
      values are simply assigned to the result record under these keys.  Only
      exceptions are listed here.
  
      Parameters
      ----------
      ds
        If given, the `path` and `type` values are populated with the path of the
        datasets and 'dataset' as the type. Giving additional values for both
        keys will overwrite these pre-populated values.
      exception
        Exceptions that occurred while generating a result should be captured
        by immediately instantiating a CapturedException. This instance can
        be passed here to yield more comprehensive error reporting, including
        an auto-generated traceback (added to the result record under an
        'exception_traceback' key). Exceptions of other types are also supported.
  
      Returns
      -------
      dict
      """
  
      d: dict[str, Any] = {}
      if action is not None:
          d["action"] = action
      if ds:
          d["path"] = ds.path
          d["type"] = "dataset"
      # now overwrite automatic
      if path is not None:
          d["path"] = path
      if type:
          d["type"] = type
      if logger:
          d["logger"] = logger
      if refds:
          d["refds"] = refds
      if status is not None:
          # TODO check for known status label
          d["status"] = status
      if message is not None:
          d["message"] = message
      if error_message is not None:
          d["error_message"] = error_message
      if exception is not None:
          d["exception"] = exception
          d["exception_traceback"] = (
              exception.format_oneline_tb(include_str=False)
              if isinstance(exception, CapturedException)
              else format_oneline_tb(exception, include_str=False)
          )
          if error_message is None and isinstance(
              exception, CapturedException
          ):
              d["error_message"] = exception.message
          if isinstance(exception, CommandError):
              d["exit_code"] = exception.code
      if kwargs:
          d.update(kwargs)
      return d
  
imports: from __future__ import annotations
  import logging
  from collections.abc import Iterable, Iterator
  from os.path import isabs, isdir
  from os.path import join
  from os.path import normpath, relpath
  from typing import Any, Optional
  from datalad.distribution.dataset import Dataset
  from datalad.support.exceptions import CapturedException, CommandError, format_oneline_tb
  from datalad.support.path import robust_abspath
  from datalad.utils import PurePosixPath, ensure_list, path_is_subpath
label_desc: Use image node_id 1 for calling a global function with example usage: get_status_dict(action, ds, path, type, logger, refds, status, message, exception, error_message) and returns: d