docstr: Actually cleanup all the remaining resources in order of specified
  priorities. Resources with bigger priority numbers are cleaned up first (have higher priority)
  while the resources with equal priorities are cleaned up in reverse order
  of their registration (hence why reversed is used).
  This is called automatically by atexit. It is not meant tobe called manually.
docstr_tok: ["Actually","cleanup","all","the","remaining","resources","in","order","of","specified","priorities",".","Resources","with","bigger","priority","numbers","are","cleaned","up","first","(","have","higher","priority",")","while","the","resources","with","equal","priorities","are","cleaned","up","in","reverse","order","of","their","registration","(","hence","why","reversed","is","used",")",".","This","is","called","automatically","by","atexit",".","It","is","not","meant","tobe","called","manually","."]
code: def _cleanup():
      """
      Actually cleanup all the remaining resources in order of specified
      priorities. Resources with bigger priority numbers are cleaned up first (have higher priority)
      while the resources with equal priorities are cleaned up in reverse order
      of their registration (hence why reversed is used).
      This is called automatically by atexit. It is not meant tobe called manually.
      """
  
      finalizers = sorted(
          AutoClean._finalizers.items(), key=lambda x: x[1][0]
      )
      logger.debug(
          f"Cleaning up...  Found {len(finalizers)} finalizers"
      )
      logger.debug("Cleaning up...  Iterating over instances in order")
      for key, (priority, finalizer) in reversed(finalizers):
          logger.debug(
              f"Cleaning up...  with priority={priority} instance {key}"
          )
          finalizer()
      AutoClean.stop_signal.set()
  
file_path: aim/aim/ext/cleanup/__init__.py
imports: import time
  from abc import abstractmethod
  import atexit
  import weakref
  import logging
  import threading
  from typing import Generic, Tuple, TypeVar, Dict
label_desc: Use image node_id 4 for calling the AutoClean obj's underlying member method code with example usage: obj._cleanup() without return types