code: def test_stages(tmp_dir, dvc):
      def collect_stages():
          return {
              stage.relpath
              for stage in Repo(os.fspath(tmp_dir)).index.stages
          }
  
      tmp_dir.dvc_gen(
          {"file": "a", "dir/file": "b", "dir/subdir/file": "c"}
      )
  
      assert collect_stages() == {
          "file.dvc",
          os.path.join("dir", "file.dvc"),
          os.path.join("dir", "subdir", "file.dvc"),
      }
  
      tmp_dir.gen(".dvcignore", "dir")
  
      assert collect_stages() == {"file.dvc"}
  
imports: import os
  from operator import itemgetter
  import pytest
  from funcy import raiser
  from dvc.dvcfile import PROJECT_FILE, FileIsGitIgnored
  from dvc.exceptions import NoOutputOrStageError
  from dvc.repo import Repo
  from dvc.stage.exceptions import StageFileDoesNotExistError, StageNameUnspecified, StageNotFound
  from dvc.utils import relpath
  from dvc.utils.fs import remove
  from dvc.utils.strictyaml import YAMLValidationError
label_desc: Use image node_id 4 for calling a global function with example usage: test_stages(tmp_dir, dvc) and returns: unknown