code: def test_replace_multiple_types():
      class OtherSource:
          pass
  
      scanner = _PyObjScanner(source_type=(Source, OtherSource))
      my_objs = [
          Source(),
          [Source(), {"key": Source(), "key2": OtherSource()}],
      ]
  
      found = scanner.find_nodes(my_objs)
      assert len(found) == 4
  
      replaced = scanner.replace_nodes(
          {obj: 1 if isinstance(obj, Source) else 2 for obj in found}
      )
      assert replaced == [1, [1, {"key": 1, "key2": 2}]]
  
file_path: ray/python/ray/dag/tests/test_py_obj_scanner.py
imports: import pytest
  from typing import Any
  from ray.dag.py_obj_scanner import _PyObjScanner, _instances
label_desc: Use image node_id 2 for calling a global function with example usage: test_replace_multiple_types() without return types