code: def _query_remotes(
      ds,
      repo,
      name,
      known_remotes,
      get_annex_info=True,
      res_kwargs=None,
      **unused_kwargs,
  ):
      res_kwargs = res_kwargs or {}
      annex_info = {}
      available_space = None
      want_annex_info = get_annex_info and isinstance(repo, AnnexRepo)
      if want_annex_info:
          # pull repo info from annex
          try:
              # need to do in safety net because of gh-1560
              raw_info = repo.repo_info(fast=True)
          except CommandError:
              raw_info = {}
          available_space = raw_info.get(
              "available local disk space", None
          )
          for trust in ("trusted", "semitrusted", "untrusted"):
              ri = raw_info.get("{} repositories".format(trust), [])
              for r in ri:
                  uuid = r.get(
                      "uuid", "00000000-0000-0000-0000-00000000000"
                  )
                  if uuid.startswith(
                      "00000000-0000-0000-0000-00000000000"
                  ):
                      continue
                  ainfo = annex_info.get(uuid, {})
                  ainfo["description"] = r.get("description", None)
                  annex_info[uuid] = ainfo
      # treat the local repo as any other remote using 'here' as a label
      remotes = [name] if name else ["here"] + known_remotes
      special_remote_info = None
      if want_annex_info:
          # query it once here, and inspect per-remote further down
          special_remote_info = repo.get_special_remotes()
  
      for remote in remotes:
          info = get_status_dict(
              action="query-sibling",
              path=ds.path,
              type="sibling",
              name=remote,
              **res_kwargs,
          )
          if remote != "here" and remote not in known_remotes:
              info["status"] = "error"
              info["message"] = "unknown sibling name"
              yield info
              continue
          # now pull everything we know out of the config
          # simply because it is cheap and we don't have to go through
          # tons of API layers to be able to work with it
          if remote == "here":
              # special case: this repo
              # aim to provide info using the same keys as for remotes
              # (see below)
              for src, dst in (
                  ("annex.uuid", "annex-uuid"),
                  ("core.bare", "annex-bare"),
                  ("annex.version", "annex-version"),
              ):
                  val = ds.config.get(src, None)
                  if val is None:
                      continue
                  info[dst] = val
              if available_space is not None:
                  info["available_local_disk_space"] = available_space
          else:
              # common case: actual remotes
              for remotecfg in [
                  k
                  for k in ds.config.keys()
                  if k.startswith("remote.{}.".format(remote))
              ]:
                  info[remotecfg[8 + len(remote) :]] = ds.config[
                      remotecfg
                  ]
          if get_annex_info and info.get("annex-uuid", None):
              ainfo = annex_info.get(info["annex-uuid"], {})
              annex_description = ainfo.get("description", None)
              if annex_description is not None:
                  info["annex-description"] = annex_description
          if want_annex_info:
              if not repo.is_remote_annex_ignored(remote):
                  try:
                      for prop in ("wanted", "required", "group"):
                          var = repo.get_preferred_content(
                              prop, "." if remote == "here" else remote
                          )
                          if var:
                              info["annex-{}".format(prop)] = var
                      groupwanted = repo.get_groupwanted(remote)
                      if groupwanted:
                          info["annex-groupwanted"] = groupwanted
                  except CommandError as exc:
                      if "cannot determine uuid" in exc.stderr:
                          ce = CapturedException(exc)
                          repo.config.reload()
                          if repo.is_remote_annex_ignored(remote):
                              lgr.warning(
                                  "%s was marked by git-annex as annex-ignore."
                                  "Edit .git/config to reset if you think that "
                                  "was done by mistake due to absent "
                                  "connection etc.",
                                  remote,
                              )
                              info["annex-ignore"] = True
                      else:
                          raise
              else:
                  info["annex-ignore"] = True
  
          if special_remote_info:
              # pull out special remote info for this remote, if there is any
              for k, v in special_remote_info.get(
                  info.get("annex-uuid"), {}
              ).items():
                  info[f"annex-{k}"] = v
  
          info["status"] = "ok"
          yield info
  
imports: import logging
  import os
  import os.path
  from urllib.parse import urlparse
  import datalad.support.ansi_colors
  from datalad.distribution.dataset import Dataset, require_dataset
  from datalad.distribution.update import Update
  from datalad.downloaders.credentials import UserPassword
  from datalad.interface.base import Interface, build_doc, eval_results
  from datalad.interface.common_opts import annex_group_opt, annex_groupwanted_opt, annex_required_opt, annex_wanted_opt, as_common_datasrc, inherit_opt, location_description, publish_by_default, publish_depends, recursion_flag, recursion_limit
  from datalad.interface.results import get_status_dict
  from datalad.interface.utils import generic_result_renderer
  from datalad.support.annexrepo import AnnexRepo
  from datalad.support.constraints import EnsureBool, EnsureChoice, EnsureNone, EnsureStr
  from datalad.support.exceptions import AccessDeniedError, AccessFailedError, CapturedException, CommandError, DownloadError, InsufficientArgumentsError, RemoteNotAvailableError
  from datalad.support.gitrepo import GitRepo
  from datalad.support.network import RI, URL, PathRI
  from datalad.support.param import Parameter
  from datalad.utils import Path, ensure_list, slash_join
  from .dataset import EnsureDataset, datasetmethod
label_desc: Use image node_id 4 for calling a global function with example usage: _query_remotes(ds, repo, name, known_remotes, get_annex_info, res_kwargs) without return types