code: def _add_remote(
      ds,
      repo,
      name,
      known_remotes,
      url,
      pushurl,
      as_common_datasrc,
      res_kwargs,
      **unused_kwargs,
  ):
      # TODO: allow for no url if 'inherit' and deduce from the super ds
      #       create-sibling already does it -- generalize/use
      #  Actually we could even inherit/deduce name from the super by checking
      #  which remote it is actively tracking in current branch... but may be
      #  would be too much magic
  
      # it seems that the only difference is that `add` should fail if a remote
      # already exists
      if url is None and pushurl is None:
          raise InsufficientArgumentsError(
              """insufficient information to add a sibling
              (needs at least a dataset, and any URL)."""
          )
  
      # a pushurl should always be able to fill in for a not
      # specified url, however, only when adding new remotes,
      # not when configuring existing remotes (to avoid undesired
      # overwriting of configurations), hence done here only
      if url is None:
          url = pushurl
  
      if not name:
          urlri = RI(url)
          # use the hostname as default remote name
          try:
              name = urlri.hostname
          except AttributeError:
              raise InsufficientArgumentsError(
                  "cannot derive a default remote name from '{}', "
                  "please specify a name.".format(url)
              )
          lgr.debug(
              "No sibling name given, use URL hostname '%s' as sibling name",
              name,
          )
  
      if not name:
          raise InsufficientArgumentsError("no sibling name given")
      if name in known_remotes:
          yield get_status_dict(
              action="add-sibling",
              status="error",
              path=ds.path,
              type="sibling",
              name=name,
              message=(
                  "sibling is already known: %s, use `configure` instead?",
                  name,
              ),
              **res_kwargs,
          )
          return
      # XXX this check better be done in configure too
      # see https://github.com/datalad/datalad/issues/5914
      if as_common_datasrc == name:
          raise ValueError(
              "Sibling name ({}) and common data source name ({}) "
              "can not be identical.".format(name, as_common_datasrc)
          )
      if isinstance(RI(url), PathRI):
          # make sure any path URL is stored in POSIX conventions for consistency
          # with git's behavior (e.g. origin configured by clone)
          url = Path(url).as_posix()
      # this remote is fresh: make it known
      # just minimalistic name and URL, the rest is coming from `configure`
      repo.add_remote(name, url)
      known_remotes.append(name)
      # always copy signature from above to avoid bugs
      for r in _configure_remote(
          ds=ds,
          repo=repo,
          name=name,
          known_remotes=known_remotes,
          url=url,
          pushurl=pushurl,
          as_common_datasrc=as_common_datasrc,
          res_kwargs=res_kwargs,
          **unused_kwargs,
      ):
          if r["action"] == "configure-sibling":
              r["action"] = "add-sibling"
          yield r
  
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 2 for calling a global function with example usage: _add_remote(ds, repo, name, known_remotes, url, pushurl, as_common_datasrc, res_kwargs) without return types