code: def test_import_file_from_dir(tmp_dir, scm, dvc, erepo_dir):
      with erepo_dir.chdir():
          erepo_dir.dvc_gen(
              {
                  "dir": {
                      "1": "1",
                      "2": "2",
                      "subdir": {"foo": "foo", "bar": "bar"},
                  }
              },
              commit="create dir",
          )
  
      stage = dvc.imp(os.fspath(erepo_dir), os.path.join("dir", "1"))
  
      assert (tmp_dir / "1").read_text() == "1"
      assert scm.is_ignored("1")
      assert stage.deps[0].def_repo == {
          "url": os.fspath(erepo_dir),
          "rev_lock": erepo_dir.scm.get_rev(),
      }
  
      dvc.imp(
          os.fspath(erepo_dir), os.path.join("dir", "2"), out="file"
      )
      assert (tmp_dir / "file").read_text() == "2"
      assert (tmp_dir / "file.dvc").exists()
  
      dvc.imp(os.fspath(erepo_dir), os.path.join("dir", "subdir"))
      assert (tmp_dir / "subdir" / "foo").read_text() == "foo"
      assert (tmp_dir / "subdir" / "bar").read_text() == "bar"
      assert (tmp_dir / "subdir.dvc").exists()
  
      dvc.imp(
          os.fspath(erepo_dir),
          os.path.join("dir", "subdir", "foo"),
          out="X",
      )
      assert (tmp_dir / "X").read_text() == "foo"
      assert (tmp_dir / "X.dvc").exists()
  
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 7 for calling a global function with example usage: test_import_file_from_dir(tmp_dir, scm, dvc, erepo_dir) without return types