class_docstr: Keep all numbers in memory.
  
  Objects that can't be aggregated like strings, tensors, images can't be stored in the buffer.
  To persist them, please use :class:`PickleWriter`.
  
  Every time, Log buffer receives a new metric, the callback is triggered,
  which is useful when tracking metrics inside a trainer.
  
  Parameters
  ----------
  callback
      A callback receiving three arguments:
  
      - on_episode: Whether it's called at the end of an episode
      - on_collect: Whether it's called at the end of a collect
      - log_buffer: the :class:`LogBbuffer` object
  
      No return value is expected.
class_docstr_tok: ["Keep","all","numbers","in","memory",".","Objects","that","ca","n't","be","aggregated","like","strings",",","tensors",",","images","ca","n't","be","stored","in","the","buffer",".","To","persist","them",",","please","use",":","class",":","`","PickleWriter","`",".","Every","time",",","Log","buffer","receives","a","new","metric",",","the","callback","is","triggered",",","which","is","useful","when","tracking","metrics","inside","a","trainer",".","Parameters","--","--","--","--","--","callback","A","callback","receiving","three","arguments",":","-","on_episode",":","Whether","it","'s","called","at","the","end","of","an","episode","-","on_collect",":","Whether","it","'s","called","at","the","end","of","a","collect","-","log_buffer",":","the",":","class",":","`","LogBbuffer","`","object","No","return","value","is","expected","."]
code: def state_dict(self) -> dict:
      return {
          **super().state_dict(),
          "latest_metrics": self._latest_metrics,
          "aggregated_metrics": self._aggregated_metrics,
      }
  
imports: from __future__ import annotations
  import logging
  from collections import defaultdict
  from enum import IntEnum
  from pathlib import Path
  from typing import TYPE_CHECKING, Any, Callable, Dict, Generic, List, Sequence, Set, Tuple, TypeVar
  import numpy
  import pandas
  from qlib.log import get_module_logger
label_desc: Use image node_id 2 for calling the LogBuffer obj's underlying member method code with example usage: obj.state_dict() and returns: dict