code: def test_subrepo(dvc_top_level, erepo):
      from tests.func.test_get import make_subrepo
  
      dvc_files = {"foo.txt": "foo.txt", "dvc_dir": {"lorem": "lorem"}}
      scm_files = {"bar.txt": "bar.txt", "scm_dir": {"ipsum": "ipsum"}}
      subrepo = erepo / "subrepo"
      make_subrepo(subrepo, erepo.scm)
  
      for repo in [erepo, subrepo]:
          with repo.chdir():
              repo.scm_gen(
                  scm_files, commit=f"scm track for top {repo}"
              )
              if hasattr(repo, "dvc"):
                  repo.dvc_gen(
                      dvc_files, commit=f"dvc track for {repo}"
                  )
  
      def _list_files(repo, path=None):
          return set(
              map(itemgetter("path"), Repo.ls(os.fspath(repo), path))
          )
  
      extras = {".dvcignore", ".gitignore"}
      git_tracked_outputs = {"bar.txt", "scm_dir"}
      dvc_files = {"dvc_dir", "foo.txt", "foo.txt.dvc", "dvc_dir.dvc"}
      common_outputs = git_tracked_outputs | extras | dvc_files
  
      top_level_outputs = (
          common_outputs if dvc_top_level else git_tracked_outputs
      )
      assert _list_files(erepo) == top_level_outputs
      assert _list_files(erepo, "scm_dir") == {"ipsum"}
      if dvc_top_level:
          assert _list_files(erepo, "dvc_dir") == {"lorem"}
  
      assert _list_files(subrepo, ".") == common_outputs
      assert _list_files(subrepo, "scm_dir") == {"ipsum"}
      assert _list_files(subrepo, "dvc_dir") == {"lorem"}
  
imports: import os
  import shutil
  import textwrap
  from operator import itemgetter
  import pytest
  from dvc.repo import Repo
  from dvc.scm import CloneError
label_desc: Use image node_id 31 for calling a global function with example usage: test_subrepo(dvc_top_level, erepo) and returns: set