code: def test_chained_import(
      tmp_dir, dvc, make_tmp_dir, erepo_dir, local_cloud
  ):
      erepo_dir.add_remote(config=local_cloud.config)
      with erepo_dir.chdir():
          erepo_dir.dvc_gen(
              {"dir": {"foo": "foo", "bar": "bar"}}, commit="init"
          )
      erepo_dir.dvc.push()
      remove(erepo_dir.dvc.cache.local.path)
      remove(os.fspath(erepo_dir / "dir"))
  
      erepo2 = make_tmp_dir("erepo2", scm=True, dvc=True)
      with erepo2.chdir():
          erepo2.dvc.imp(os.fspath(erepo_dir), "dir")
          erepo2.scm.add("dir.dvc")
          erepo2.scm.commit("import")
      remove(erepo2.dvc.cache.local.path)
      remove(os.fspath(erepo2 / "dir"))
  
      dvc.imp(os.fspath(erepo2), "dir", "dir_imported")
      dst = tmp_dir / "dir_imported"
      assert (dst / "foo").read_text() == "foo"
      assert (dst / "bar").read_text() == "bar"
  
      dvc.cache.local.clear()
      remove("dir_imported")
  
      # pulled objects should come from the original upstream repo's remote,
      # no cache or remote should be needed from the intermediate repo
      dvc.pull(["dir_imported.dvc"])
      assert not os.path.exists(erepo_dir.dvc.cache.local.path)
      assert not os.path.exists(erepo2.dvc.cache.local.path)
      assert (dst / "foo").read_text() == "foo"
      assert (dst / "bar").read_text() == "bar"
  
imports: import filecmp
  import os
  import pytest
  from funcy import first
  from dvc.cachemgr import CacheManager
  from dvc.config import NoRemoteError
  from dvc.dvcfile import load_file
  from dvc.fs import system
  from dvc.scm import Git
  from dvc.stage.exceptions import StagePathNotFoundError
  from dvc.testing.tmp_dir import make_subrepo
  from dvc.utils.fs import remove
  from dvc_data.index.index import DataIndexDirError
label_desc: Use image node_id 33 for calling a global function with example usage: test_chained_import(tmp_dir, dvc, make_tmp_dir, erepo_dir, local_cloud) without return types