code: def test_stage_collection(tmp_dir, dvc):
      tmp_dir.gen(
          {
              "dir": {"file1": "file1", "file2": "file2"},
              "foo": "foo",
              "bar": "bar",
          }
      )
      (stage1,) = dvc.add("dir")
      stage2 = dvc.run(
          cmd="cp foo foo2",
          deps=["foo"],
          name="copy-foo-foo2",
          metrics=["foo2"],
          always_changed=True,
      )
      assert set(dvc.index.stages) == {stage1, stage2}
  
imports: import textwrap
  import pytest
  from dvc.annotations import Annotation
  from dvc.dvcfile import LOCK_FILE, PROJECT_FILE, ParametrizedDumpError, SingleStageFile, load_file
  from dvc.stage.exceptions import StageFileDoesNotExistError
  from dvc.stage.loader import StageNotFound
  from dvc.utils.strictyaml import YAMLValidationError
label_desc: Use image node_id 9 for calling a global function with example usage: test_stage_collection(tmp_dir, dvc) without return types