class_docstr: Logger which auto closes itself on exit if not already closed.
class_docstr_tok: ["Logger","which","auto","closes","itself","on","exit","if","not","already","closed","."]
code: def __init__(self, logger: base.Logger):
      self._logger = logger
      # The finalizer "logger.close" is invoked in one of the following scenario:
      # 1) the current logger is GC
      # 2) from the python doc, when the program exits, each remaining live
      #    finalizer is called.
      # Note that in the normal flow, where "close" is explicitly called,
      # the finalizer is marked as dead using the detach function so that
      # the underlying logger is not closed twice (once explicitly and once
      # implicitly when the object is GC or when the program exits).
      self._finalizer = weakref.finalize(self, logger.close)
  
imports: import weakref
  from acme.utils.loggers import base
label_desc: Use image node_id 1 to create a new AutoCloseLogger object from inherited base classes: base with example: obj = AutoCloseLogger(logger)