code: def test_used_objs(tmp_dir, scm, dvc, run_copy):
      from dvc_data.hashfile.hash_info import HashInfo
  
      dvc.scm_context.autostage = True
      tmp_dir.dvc_gen(
          {"dir": {"subdir": {"file": "file"}}, "foo": "foo"}
      )
      run_copy("foo", "bar", name="copy-foo-bar")
      scm.commit("commit")
  
      for _ in dvc.brancher(revs=["HEAD"]):
          expected_objs = [
              HashInfo(
                  name="md5",
                  value="acbd18db4cc2f85cedef654fccc4a4d8",
                  obj_name="bar",
              ),
              HashInfo(
                  name="md5",
                  value="8c7dd922ad47494fc02c388e12c00eac",
                  obj_name="dir/subdir/file",
              ),
              HashInfo(
                  name="md5",
                  value="d28c9e28591aeb7e303dc6772ffa6f6b.dir",
                  obj_name="dir",
              ),
          ]
  
          assert dvc.index.used_objs() == {None: set(expected_objs)}
          assert dvc.index.used_objs("dir") == {
              None: set(expected_objs[1:])
          }
          assert dvc.index.used_objs(".", recursive=True) == {
              None: set(expected_objs)
          }
          assert dvc.index.used_objs(
              "copy-foo-bar", with_deps=True
          ) == {None: {expected_objs[0]}}
  
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 8 for calling a global function with example usage: test_used_objs(tmp_dir, scm, dvc, run_copy) without return types