class_docstr: Write log messages to console periodically.
  
  It tracks an average meter for each metric, which is the average value since last ``clear()`` till now.
  The display format for each metric is ``<name> <latest_value> (<average_value>)``.
  
  Non-single-number metrics are auto skipped.
class_docstr_tok: ["Write","log","messages","to","console","periodically",".","It","tracks","an","average","meter","for","each","metric",",","which","is","the","average","value","since","last","``","clear","(",")","``","till","now",".","The","display","format","for","each","metric","is","``","<","name",">","<","latest_value",">","(","<","average_value",">",")","``",".","Non-single-number","metrics","are","auto","skipped","."]
code: def __init__(
      self,
      log_every_n_episode: int = 20,
      total_episodes: int | None = None,
      float_format: str = ":.4f",
      counter_format: str = ":4d",
      loglevel: int | LogLevel = LogLevel.PERIODIC,
  ) -> None:
      super().__init__(loglevel)
      # TODO: support log_every_n_step
      self.log_every_n_episode = log_every_n_episode
      self.total_episodes = total_episodes
  
      self.counter_format = counter_format
      self.float_format = float_format
  
      self.prefix = ""
  
      self.console_logger = get_module_logger(
          __name__, level=logging.INFO
      )
  
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 1 to create a new ConsoleWriter object from inherited base classes: LogWriter with example: obj = ConsoleWriter(log_every_n_episode, total_episodes, float_format, counter_format, loglevel)