class_docstr: Base class for log writers, triggered at every reset and step by finite env.
  
  What to do with a specific log depends on the implementation of subclassing :class:`LogWriter`.
  The general principle is that, it should handle logs above its loglevel (inclusive),
  and discard logs that are not acceptable. For instance, console loggers obviously can't handle an image.
class_docstr_tok: ["Base","class","for","log","writers",",","triggered","at","every","reset","and","step","by","finite","env",".","What","to","do","with","a","specific","log","depends","on","the","implementation","of","subclassing",":","class",":","`","LogWriter","`",".","The","general","principle","is","that",",","it","should","handle","logs","above","its","loglevel","(","inclusive",")",",","and","discard","logs","that","are","not","acceptable",".","For","instance",",","console","loggers","obviously","ca","n't","handle","an","image","."]
docstr: Aggregation function from step-wise to episode-wise.
  
  If it's a sequence of float, take the mean.
  Otherwise, take the first element.
  
  If a name is specified and,
  
  - if it's ``reward``, the reduction will be sum.
code: def aggregation(array: Sequence[Any], name: str | None = None) -> Any:
      """Aggregation function from step-wise to episode-wise.
  
      If it's a sequence of float, take the mean.
      Otherwise, take the first element.
  
      If a name is specified and,
  
      - if it's ``reward``, the reduction will be sum.
      """
      assert len(array) > 0, "The aggregated array must be not empty."
      if all(isinstance(v, float) for v in array):
          if name == "reward":
              return np.sum(array)
          return np.mean(array)
      else:
          return array[0]
  
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 5 for calling the LogWriter obj's underlying member method code with example usage: obj.aggregation(array, name) and returns: np, array, np