code: def dash_R_cleanup(fs, ps, pic, zdc, abcs):
      import copyreg
      import collections.abc
  
      # Restore some original values.
      warnings.filters[:] = fs
      copyreg.dispatch_table.clear()
      copyreg.dispatch_table.update(ps)
      sys.path_importer_cache.clear()
      sys.path_importer_cache.update(pic)
      try:
          import zipimport
      except ImportError:
          pass  # Run unmodified on platforms without zipimport support
      else:
          zipimport._zip_directory_cache.clear()
          zipimport._zip_directory_cache.update(zdc)
  
      # Clear ABC registries, restoring previously saved ABC registries.
      # ignore deprecation warning for collections.abc.ByteString
      abs_classes = [
          getattr(collections.abc, a) for a in collections.abc.__all__
      ]
      abs_classes = filter(isabstract, abs_classes)
      for abc in abs_classes:
          for obj in abc.__subclasses__() + [abc]:
              for ref in abcs.get(obj, set()):
                  if ref() is not None:
                      obj.register(ref())
              obj._abc_caches_clear()
  
      # Clear caches
      clear_caches()
  
      # Clear type cache at the end: previous function calls can modify types
      sys._clear_type_cache()
  
file_path: cpython/Lib/test/libregrtest/refleak.py
imports: import sys
  import warnings
  from inspect import isabstract
  from typing import Any
  from test import support
  from test.support import os_helper
  from .runtests import HuntRefleak
  from .utils import clear_caches
label_desc: Use image node_id 2 for calling a global function with example usage: dash_R_cleanup(fs, ps, pic, zdc, abcs) without return types