code: def test_install_recursive(src=None, path_nr=None, path_r=None):
      _make_dataset_hierarchy(src)
  
      # first install non-recursive:
      ds = install(path_nr, source=src, recursive=False)
      ok_(ds.is_installed())
      for sub in ds.subdatasets(recursive=True, result_xfm="datasets"):
          ok_(
              not sub.is_installed(),
              "Unintentionally installed: %s" % (sub,),
          )
      # this also means, subdatasets to be listed as absent:
      eq_(
          set(
              ds.subdatasets(
                  recursive=True, state="absent", result_xfm="relpaths"
              )
          ),
          {"sub1"},
      )
  
      # now recursively:
      # don't filter implicit results so we can inspect them
      res = install(
          path_r,
          source=src,
          recursive=True,
          result_xfm=None,
          result_filter=None,
      )
      # installed a dataset and four subdatasets
      assert_result_count(res, 5, action="install", type="dataset")
      # we recurse top down during installation, so toplevel should appear at
      # first position in returned list
      eq_(res[0]["path"], path_r)
      top_ds = Dataset(res[0]["path"])
      ok_(top_ds.is_installed())
  
      # the subdatasets are contained in returned list:
      # (Note: Until we provide proper (singleton) instances for Datasets,
      # need to check for their paths)
      assert_in_results(
          res, path=opj(top_ds.path, "sub1"), type="dataset"
      )
      assert_in_results(
          res, path=opj(top_ds.path, "sub1", "sub2"), type="dataset"
      )
      assert_in_results(
          res,
          path=opj(top_ds.path, "sub1", "sub2", "sub3"),
          type="dataset",
      )
      assert_in_results(
          res,
          path=opj(top_ds.path, "sub1", "sub2", "sub3", "sub4"),
          type="dataset",
      )
  
      eq_(len(top_ds.subdatasets(recursive=True)), 4)
  
      for subds in top_ds.subdatasets(
          recursive=True, result_xfm="datasets"
      ):
          ok_(subds.is_installed(), "Not installed: %s" % (subds,))
          # no content was installed:
          ainfo = subds.repo.get_content_annexinfo(
              init=None, eval_availability=True
          )
          assert_false(any(st["has_content"] for st in ainfo.values()))
      # no absent subdatasets:
      ok_(top_ds.subdatasets(recursive=True, state="absent") == [])
  
      # check if we can install recursively into a dataset
      # https://github.com/datalad/datalad/issues/2982
      subds = ds.install("recursive-in-ds", source=src, recursive=True)
      ok_(subds.is_installed())
      for subsub in subds.subdatasets(
          recursive=True, result_xfm="datasets"
      ):
          ok_(subsub.is_installed())
  
      # check that we get subdataset instances manufactured from notneeded results
      # to install existing subdatasets again
      eq_(subds, ds.install("recursive-in-ds"))
  
imports: import logging
  import os
  from os.path import basename, dirname, exists, isdir
  from os.path import join
  from unittest.mock import patch
  import pytest
  from datalad import cfg
  from datalad.api import create, get, install
  from datalad.cmd import WitlessRunner
  from datalad.interface.results import YieldDatasets
  from datalad.support import path
  from datalad.support.annexrepo import AnnexRepo
  from datalad.support.exceptions import IncompleteResultsError, InsufficientArgumentsError
  from datalad.support.gitrepo import GitRepo
  from datalad.support.network import get_local_file_url
  from datalad.tests.utils_testdatasets import _make_dataset_hierarchy, _mk_submodule_annex
  from datalad.tests.utils_pytest import DEFAULT_BRANCH, DEFAULT_REMOTE, assert_false, assert_in, assert_in_results, assert_is_instance, assert_not_in, assert_raises, assert_repo_status, assert_result_count, assert_status, create_tree, eq_, get_datasets_topdir, integration, known_failure_githubci_win, known_failure_windows, ok_, ok_file_has_content, ok_startswith, put_file_under_git, serve_path_via_http, skip_if_no_network, skip_if_on_windows, skip_ssh, slow, swallow_logs, use_cassette, usecase, with_tempfile, with_tree
  from datalad.utils import Path, _path_, chpwd, getpwd, on_windows, rmtree
  from ..dataset import Dataset
label_desc: Use image node_id 10 for calling a global function with example usage: test_install_recursive(src, path_nr, path_r) without return types