code: def test_collect_dir_recursive(tmp_dir, dvc, run_head):
      tmp_dir.gen({"dir": {"foo": "foo"}})
      (stage1,) = dvc.add("dir/*", glob=True)
      with (tmp_dir / "dir").chdir():
          stage2 = run_head("foo", name="head-foo")
          stage3 = run_head("foo-1", name="head-foo1")
      assert set(dvc.stage.collect("dir", recursive=True)) == {
          stage1,
          stage2,
          stage3,
      }
  
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 2 for calling a global function with example usage: test_collect_dir_recursive(tmp_dir, dvc, run_head) without return types