code: def yield_dataset_status(
      ds,
      paths,
      annexinfo,
      untracked,
      recursion_limit,
      queried,
      eval_submodule_state,
      eval_filetype,
      cache,
      reporting_order,
  ):
      """Internal helper to obtain status information on a dataset
  
      Parameters
      ----------
      ds : Dataset
        Dataset to get the status of.
      path : Path-like, optional
        Paths to constrain the status to (see main status() command).
      annexinfo : str
        Annex information reporting mode (see main status() command).
      untracked : str, optional
        Reporting mode for untracked content (see main status() command).
      recursion_limit : int, optional
      queried : set
        Will be populated with a Path instance for each queried dataset.
      eval_submodule_state : str
        Submodule evaluation mode setting for Repo.diffstatus().
      eval_filetype : bool, optional
        THIS OPTION IS IGNORED. It will be removed in a future release.
      cache : dict
        Cache to be passed on to all Repo.diffstatus() calls to avoid duplicate
        queries.
      reporting_order : {'depth-first', 'breadth-first'}, optional
        By default, subdataset content records are reported after the record
        on the subdataset's submodule in a superdataset (depth-first).
        Alternatively, report all superdataset records first, before reporting
        any subdataset content records (breadth-first).
  
      Yields
      ------
      dict
        DataLad result records.
      """
      if eval_filetype is not None:
          warnings.warn(
              "yield_dataset_status(eval_filetype=) no longer supported, "
              "and will be removed in a future release",
              DeprecationWarning,
          )
  
      if reporting_order not in ("depth-first", "breadth-first"):
          raise ValueError(
              "Unknown reporting order: {}".format(reporting_order)
          )
  
      if ds.pathobj in queried:
          # do not report on a single dataset twice
          return
      # take the dataset that went in first
      repo = ds.repo
      repo_path = repo.pathobj
      lgr.debug("Querying %s.diffstatus() for paths: %s", repo, paths)
      # recode paths with repo reference for low-level API
      paths = (
          [repo_path / p.relative_to(ds.pathobj) for p in paths]
          if paths
          else None
      )
      status = repo.diffstatus(
          fr="HEAD" if repo.get_hexsha() else None,
          to=None,
          paths=paths,
          untracked=untracked,
          eval_submodule_state=eval_submodule_state,
          _cache=cache,
      )
      if annexinfo and hasattr(repo, "get_content_annexinfo"):
          if paths:
              # when an annex query has been requested for specific paths,
              # exclude untracked files from the annex query (else gh-7032)
              untracked = [
                  k
                  for k, v in status.items()
                  if v["state"] == "untracked"
              ]
              lgr.debug(
                  "Skipping %s.get_content_annexinfo() for untracked paths: %s",
                  repo,
                  paths,
              )
              [paths.remove(p) for p in untracked]
          lgr.debug(
              "Querying %s.get_content_annexinfo() for paths: %s",
              repo,
              paths,
          )
          # this will amend `status`
          repo.get_content_annexinfo(
              paths=paths,
              init=status,
              eval_availability=annexinfo in ("availability", "all"),
              ref=None,
          )
      # potentially collect subdataset status call specs for the end
      # (if order == 'breadth-first')
      subds_statuscalls = []
      for path, props in status.items():
          cpath = ds.pathobj / path.relative_to(repo_path)
          yield dict(
              props,
              path=str(cpath),
              # report the dataset path rather than the repo path to avoid
              # realpath/symlink issues
              parentds=ds.path,
          )
          queried.add(ds.pathobj)
          if recursion_limit and props.get("type", None) == "dataset":
              if cpath == ds.pathobj:
                  # ATM can happen if there is something wrong with this repository
                  # We will just skip it here and rely on some other exception to bubble up
                  # See https://github.com/datalad/datalad/pull/4526 for the usecase
                  lgr.debug(
                      "Got status for itself, which should not happen, skipping %s",
                      path,
                  )
                  continue
              subds = Dataset(str(cpath))
              if subds.is_installed():
                  call_args = (
                      subds,
                      None,
                      annexinfo,
                      untracked,
                      recursion_limit - 1,
                      queried,
                      eval_submodule_state,
                      None,
                      cache,
                  )
                  call_kwargs = dict(
                      reporting_order="depth-first",
                  )
                  if reporting_order == "depth-first":
                      yield from yield_dataset_status(
                          *call_args, **call_kwargs
                      )
                  else:
                      subds_statuscalls.append((call_args, call_kwargs))
  
      # deal with staged subdataset status calls
      for call_args, call_kwargs in subds_statuscalls:
          yield from yield_dataset_status(*call_args, **call_kwargs)
  
imports: import logging
  import os
  import os.path
  from collections import OrderedDict
  import warnings
  from datalad.utils import bytes2human, ensure_list, ensure_unicode, get_dataset_root
  from datalad.interface.base import Interface, build_doc, eval_results
  from datalad.interface.common_opts import recursion_limit, recursion_flag
  from datalad.interface.utils import generic_result_renderer
  import datalad.support.ansi_colors
  from datalad.support.param import Parameter
  from datalad.support.constraints import EnsureChoice, EnsureNone, EnsureStr
  from datalad.distribution.dataset import Dataset, EnsureDataset, datasetmethod, require_dataset, resolve_path, path_under_rev_dataset
  import datalad.utils
  from datalad.dochelpers import single_or_plural
label_desc: Use image node_id 1 for calling a global function with example usage: yield_dataset_status(ds, paths, annexinfo, untracked, recursion_limit, queried, eval_submodule_state, eval_filetype, cache, reporting_order) without return types