code: def test_scanner_clear():
      """Test scanner clear to make the scanner GCable"""
      prev_len = len(_instances)
  
      def call_find_nodes():
          scanner = _PyObjScanner(source_type=Source)
          my_objs = [Source(), [Source(), {"key": Source()}]]
          scanner.find_nodes(my_objs)
          scanner.clear()
          assert id(scanner) not in _instances
  
      call_find_nodes()
      assert prev_len == len(_instances)
  
      def call_find_and_replace_nodes():
          scanner = _PyObjScanner(source_type=Source)
          my_objs = [Source(), [Source(), {"key": Source()}]]
          found = scanner.find_nodes(my_objs)
          scanner.replace_nodes({obj: 1 for obj in found})
          scanner.clear()
          assert id(scanner) not in _instances
  
      call_find_and_replace_nodes()
      assert prev_len == len(_instances)
  
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 4 for calling a global function with example usage: test_scanner_clear() without return types