code: def test_collect(tmp_dir, scm, dvc, run_copy):
      def collect_outs(*args, **kwargs):
          return {
              str(out)
              for stage in dvc.stage.collect(*args, **kwargs)
              for out in stage.outs
          }
  
      tmp_dir.dvc_gen("foo", "foo")
      run_copy("foo", "bar", name="copy-foo-bar")
      scm.add([".gitignore", "foo.dvc", "dvc.yaml", "dvc.lock"])
      scm.commit("Add foo and bar")
  
      scm.checkout("new-branch", create_new=True)
  
      run_copy("bar", "buzz", name="copy-bar-buzz")
      scm.add([".gitignore", "dvc.yaml", "dvc.lock"])
      scm.commit("Add buzz")
  
      assert collect_outs("copy-foo-bar", with_deps=True) == {
          "foo",
          "bar",
      }
      assert collect_outs("copy-bar-buzz", with_deps=True) == {
          "foo",
          "bar",
          "buzz",
      }
      assert collect_outs("copy-bar-buzz", with_deps=False) == {"buzz"}
  
      run_copy("foo", "foobar", name="copy-foo-foobar")
      assert collect_outs(":copy-foo-foobar") == {"foobar"}
      assert collect_outs(":copy-foo-foobar", with_deps=True) == {
          "foobar",
          "foo",
      }
      assert collect_outs(
          "dvc.yaml:copy-foo-foobar", recursive=True
      ) == {"foobar"}
      assert collect_outs("copy-foo-foobar") == {"foobar"}
      assert collect_outs("copy-foo-foobar", with_deps=True) == {
          "foobar",
          "foo",
      }
      assert collect_outs("copy-foo-foobar", recursive=True) == {
          "foobar"
      }
  
      run_copy("foobar", "baz", name="copy-foobar-baz")
      assert collect_outs("dvc.yaml") == {
          "foobar",
          "baz",
          "bar",
          "buzz",
      }
      assert collect_outs("dvc.yaml", with_deps=True) == {
          "foobar",
          "baz",
          "bar",
          "buzz",
          "foo",
      }
  
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 1 for calling a global function with example usage: test_collect(tmp_dir, scm, dvc, run_copy) and returns: unknown