code: def test_collect_granular_with_target(tmp_dir, dvc, stages):
      assert dvc.stage.collect_granular("foo.dvc") == [
          (stages["foo-generate"], None)
      ]
      assert dvc.stage.collect_granular(PROJECT_FILE) == [
          (stages["copy-foo-bar"], None),
          (stages["copy-bar-foobar"], None),
          (stages["copy-lorem-ipsum"], None),
      ]
      assert dvc.stage.collect_granular(":") == [
          (stages["copy-foo-bar"], None),
          (stages["copy-bar-foobar"], None),
          (stages["copy-lorem-ipsum"], None),
      ]
      assert dvc.stage.collect_granular("copy-bar-foobar") == [
          (stages["copy-bar-foobar"], None)
      ]
      assert dvc.stage.collect_granular(":copy-bar-foobar") == [
          (stages["copy-bar-foobar"], None)
      ]
      assert dvc.stage.collect_granular("dvc.yaml:copy-bar-foobar") == [
          (stages["copy-bar-foobar"], None)
      ]
  
      with (tmp_dir / dvc.DVC_DIR).chdir():
          assert dvc.stage.collect_granular(
              relpath(tmp_dir / PROJECT_FILE) + ":copy-bar-foobar"
          ) == [(stages["copy-bar-foobar"], None)]
  
      assert dvc.stage.collect_granular("foobar") == [
          (stages["copy-bar-foobar"], os.path.join(tmp_dir, "foobar"))
      ]
  
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 10 for calling a global function with example usage: test_collect_granular_with_target(tmp_dir, dvc, stages) without return types