code: def test_replace_nested_in_obj():
      """Test that the source can be nested in arbitrary objects."""
      scanner = _PyObjScanner(source_type=Source)
  
      class Outer:
          def __init__(self, inner: Any):
              self._inner = inner
  
          def __eq__(self, other):
              return self._inner == other._inner
  
      my_objs = [
          Outer(Source()),
          Outer(Outer(Source())),
          Outer((Source(),)),
      ]
  
      found = scanner.find_nodes(my_objs)
      assert len(found) == 3
  
      replaced = scanner.replace_nodes({obj: 1 for obj in found})
      assert replaced == [Outer(1), Outer(Outer(1)), Outer((1,))]
  
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 3 for calling a global function with example usage: test_replace_nested_in_obj() and returns: unknown