code: def test_collect_generated(tmp_dir, dvc):
      d = {
          "vars": [{"vars": [1, 2, 3, 4, 5]}],
          "stages": {
              "build": {
                  "foreach": "${vars}",
                  "do": {"cmd": "echo ${item}"},
              }
          },
      }
      (tmp_dir / "dvc.yaml").dump(d)
  
      all_stages = set(dvc.index.stages)
      assert len(all_stages) == 5
  
      assert set(dvc.stage.collect()) == all_stages
      assert set(dvc.stage.collect("build")) == all_stages
      assert (
          set(dvc.stage.collect("build", with_deps=True)) == all_stages
      )
      assert set(dvc.stage.collect("build*", glob=True)) == all_stages
      assert (
          set(dvc.stage.collect("build*", glob=True, with_deps=True))
          == all_stages
      )
  
      stages_info = {(stage, None) for stage in all_stages}
      assert set(dvc.stage.collect_granular("build")) == stages_info
      assert (
          set(dvc.stage.collect_granular("build", with_deps=True))
          == stages_info
      )
  
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 7 for calling a global function with example usage: test_collect_generated(tmp_dir, dvc) without return types