code: def test_view_outs_filter(tmp_dir, scm, dvc, run_copy):
      (stage1,) = tmp_dir.dvc_gen("foo", "foo")
      stage2 = run_copy("foo", "bar", name="copy-foo-bar")
      tmp_dir.commit(
          [s.outs[0].fspath for s in (stage1, stage2)], msg="add"
      )
      index = Index.from_repo(dvc)
  
      view = index.targets_view(
          None, outs_filter=lambda o: o.def_path == "foo"
      )
      assert set(view.stages) == {stage1, stage2}
      assert {out.fs_path for out in view.outs} == {
          out.fs_path for out in stage1.outs
      }
  
imports: import os
  from itertools import chain
  import pytest
  from pygtrie import Trie
  from dvc.repo.index import Index
  from dvc.stage import Stage
label_desc: Use image node_id 12 for calling a global function with example usage: test_view_outs_filter(tmp_dir, scm, dvc, run_copy) without return types