code: def _test_target_ssh_inherit(
      standardgroup, ui, use_ssh, src_path, target_path
  ):
      ds = Dataset(src_path).create()
      if use_ssh:
          target_url = "datalad-test:%s" % target_path
      else:
          target_url = target_path
      remote = "magical"
      # for the test of setting a group, will just smoke test while using current
      # user's group
      ds.create_sibling(
          target_url,
          name=remote,
          shared="group",
          group=os.getgid(),
          ui=ui,
      )  # not doing recursively
      if standardgroup:
          ds.repo.set_preferred_content("wanted", "standard", remote)
          ds.repo.set_preferred_content("group", standardgroup, remote)
      ds.publish(to=remote)
  
      # now a month later we created a new subdataset... a few of the nested ones
      # A known hiccup happened when there
      # is also subsub ds added - we might incorrectly traverse and not prepare
      # sub first for subsub to inherit etc
      parent_ds = ds
      subdss = []
      nlevels = 2  # gets slow: 1 - 43 sec, 2 - 49 sec , 3 - 69 sec
      for levels in range(nlevels):
          subds = parent_ds.create("sub")
          create_tree(subds.path, {"sub.dat": "lots of data"})
          parent_ds.save("sub", recursive=True)
          ok_file_under_git(subds.path, "sub.dat", annexed=True)
          parent_ds = subds
          subdss.append(subds)
  
      target_subdss = [
          Dataset(opj(*([target_path] + ["sub"] * (i + 1))))
          for i in range(nlevels)
      ]
      # since we do not have yet/thus have not used an option to record to publish
      # to that sibling by default (e.g. --set-upstream), if we run just ds.publish
      # -- should fail
      assert_result_count(
          ds.publish(on_failure="ignore"),
          1,
          status="impossible",
          message="No target sibling configured for default publication, please specify via --to",
      )
      ds.publish(
          to=remote
      )  # should be ok, non recursive; BUT it (git or us?) would
      # create an empty sub/ directory
      assert_postupdate_hooks(target_path, installed=ui)
      for target_sub in target_subdss:
          ok_(not target_sub.is_installed())  # still not there
      res = ds.publish(to=remote, recursive=True, on_failure="ignore")
      assert_result_count(res, 1 + len(subdss))
      assert_status(("error", "notneeded"), res)
      assert_result_count(
          res,
          len(subdss),
          status="error",
          message=(
              "Unknown target sibling '%s' for publication",
              "magical",
          ),
      )
  
      # Finally publishing with inheritance
      ds.publish(to=remote, recursive=True, missing="inherit")
      assert_postupdate_hooks(target_path, installed=ui)
  
      def check_dss():
          # we added the remote and set all the
          for subds in subdss:
              eq_(
                  subds.repo.get_preferred_content("wanted", remote),
                  "standard" if standardgroup else "",
              )
              eq_(
                  subds.repo.get_preferred_content("group", remote),
                  standardgroup or "",
              )
  
          for target_sub in target_subdss:
              ok_(target_sub.is_installed())  # it is there now
              eq_(
                  target_sub.repo.config.get("core.sharedrepository"),
                  "1",
              )
              # and we have transferred the content
              if standardgroup and standardgroup == "backup":
                  # only then content should be copied
                  ok_file_has_content(
                      opj(target_sub.path, "sub.dat"), "lots of data"
                  )
              else:
                  # otherwise nothing is copied by default
                  assert_false(
                      target_sub.repo.file_has_content("sub.dat")
                  )
  
      check_dss()
      # and it should be ok to reconfigure the full hierarchy of datasets
      # while "inheriting". No URL must be specified, and we must not blow
      # but just issue a warning for the top level dataset which has no super,
      # so cannot inherit anything - use case is to fixup/establish the full
      # hierarchy on the remote site
      ds.save(
          recursive=True
      )  # so we have committed hierarchy for create_sibling
      with swallow_logs(logging.WARNING) as cml:
          out = ds.create_sibling(
              None,
              name=remote,
              existing="reconfigure",
              inherit=True,
              ui=ui,
              recursive=True,
          )
          eq_(len(out), 1 + len(subdss))
          assert_in("Cannot determine super dataset", cml.out)
  
      check_dss()
  
imports: import logging
  import os
  import stat
  import sys
  from os import chmod
  from os.path import basename, exists
  from os.path import join
  import pytest
  from datalad.api import create_sibling, install, push
  from datalad.cmd import StdOutErrCapture
  from datalad.cmd import WitlessRunner
  from datalad.distribution.create_sibling import _RunnerAdapter
  from datalad.support.annexrepo import AnnexRepo
  from datalad.support.exceptions import CommandError, InsufficientArgumentsError
  from datalad.support.gitrepo import GitRepo
  from datalad.support.network import urlquote
  from datalad.tests.utils_testdatasets import _mk_submodule_annex
  from datalad.tests.utils_pytest import DEFAULT_BRANCH, DEFAULT_REMOTE, SkipTest, assert_dict_equal, assert_false, assert_in, assert_in_results, assert_no_errors_logged, assert_not_equal, assert_not_in, assert_raises, assert_repo_status, assert_result_count, assert_status, create_tree, eq_, get_mtimes_and_digests, get_ssh_port, known_failure_windows, ok_, ok_endswith, ok_file_has_content, ok_file_under_git, skip_if_on_windows, skip_if_root, skip_ssh, slow, swallow_logs, with_tempfile, with_testsui
  from datalad.utils import Path, _path_, chpwd, on_windows
  from ..dataset import Dataset
label_desc: Use image node_id 13 for calling a global function with example usage: _test_target_ssh_inherit(standardgroup, ui, use_ssh, src_path, target_path) without return types