code: def test_install_into_dataset(source=None, top_path=None):
      src_ds = Dataset(source).create(
          result_renderer="disabled", force=True
      )
      src_ds.save(["INFO.txt", "test.dat"], to_git=True)
      src_ds.save("test-annex.dat", to_git=False)
  
      ds = create(top_path)
      assert_repo_status(ds.path)
  
      subds = ds.install("sub", source=source)
      ok_(isdir(opj(subds.path, ".git")))
      ok_(subds.is_installed())
      assert_in("sub", ds.subdatasets(result_xfm="relpaths"))
      # sub is clean:
      assert_repo_status(subds.path, annex=None)
      # top is too:
      assert_repo_status(ds.path, annex=None)
      ds.save(message="addsub")
      # now it is:
      assert_repo_status(ds.path, annex=None)
  
      # but we could also save while installing and there should be no side-effect
      # of saving any other changes if we state to not auto-save changes
      # Create a dummy change
      create_tree(ds.path, {"dummy.txt": "buga"})
      assert_repo_status(ds.path, untracked=["dummy.txt"])
      subds_ = ds.install("sub2", source=source)
      eq_(subds_.path, opj(ds.path, "sub2"))  # for paranoid yoh ;)
      assert_repo_status(ds.path, untracked=["dummy.txt"])
  
      # and we should achieve the same behavior if we create a dataset
      # and then decide to add it
      create(_path_(top_path, "sub3"))
      assert_repo_status(ds.path, untracked=["dummy.txt", "sub3/"])
      ds.save("sub3")
      assert_repo_status(ds.path, untracked=["dummy.txt"])
  
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 12 for calling a global function with example usage: test_install_into_dataset(source, top_path) without return types