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 generate_log_message(self, logs: Dict[str, float]) -> str:
      if self.prefix:
          msg_prefix = self.prefix + " "
      else:
          msg_prefix = ""
      if self.total_episodes is None:
          msg_prefix += "[Step {" + self.counter_format + "}]"
      else:
          msg_prefix += (
              "[{"
              + self.counter_format
              + "}/"
              + str(self.total_episodes)
              + "]"
          )
      msg_prefix = msg_prefix.format(self.episode_count)
  
      msg = ""
      for name, value in logs.items():
          # Double-space as delimiter
          format_template = (
              r"  {} {"
              + self.float_format
              + "} ({"
              + self.float_format
              + "})"
          )
          msg += format_template.format(
              name,
              value,
              self.metric_sums[name] / self.metric_counts[name],
          )
  
      msg = msg_prefix + " " + msg
  
      return msg
  
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 4 for calling the ConsoleWriter obj's underlying member method code with example usage: obj.generate_log_message(logs) and returns: msg