code: def format_decisions(
      decisions: List[BaseTradeDecision],
  ) -> Optional[
      Tuple[str, List[Tuple[BaseTradeDecision, Union[Tuple, None]]]]
  ]:
      """
      format the decisions collected by `qlib.backtest.collect_data`
      The decisions will be organized into a tree-like structure.
  
      Parameters
      ----------
      decisions : List[BaseTradeDecision]
          decisions collected by `qlib.backtest.collect_data`
  
      Returns
      -------
      Tuple[str, List[Tuple[BaseTradeDecision, Union[Tuple, None]]]]:
  
          reformat the list of decisions into a more user-friendly format
          <decisions> :=  Tuple[<freq>, List[Tuple[<decision>, <sub decisions>]]]
          - <sub decisions> := `<decisions> in lower level` | None
          - <freq> := "day" | "30min" | "1min" | ...
          - <decision> := <instance of BaseTradeDecision>
      """
      if len(decisions) == 0:
          return None
  
      cur_freq = decisions[0].strategy.trade_calendar.get_freq()
  
      res: Tuple[str, list] = (cur_freq, [])
      last_dec_idx = 0
      for i, dec in enumerate(decisions[1:], 1):
          if dec.strategy.trade_calendar.get_freq() == cur_freq:
              res[1].append(
                  (
                      decisions[last_dec_idx],
                      format_decisions(decisions[last_dec_idx + 1 : i]),
                  )
              )
              last_dec_idx = i
      res[1].append(
          (
              decisions[last_dec_idx],
              format_decisions(decisions[last_dec_idx + 1 :]),
          )
      )
      return res
  
file_path: qlib/qlib/backtest/__init__.py
imports: from __future__ import annotations
  import copy
  from pathlib import Path
  from typing import TYPE_CHECKING, Any, Generator, List, Optional, Tuple, Union
  import pandas
  from .account import Account
  from ..config import C
  from ..log import get_module_logger
  from ..utils import init_instance_by_config
  from .backtest import INDICATOR_METRIC, PORT_METRIC, backtest_loop, collect_data_loop
  from .decision import Order
  from .exchange import Exchange
  from .utils import CommonInfrastructure
label_desc: Use image node_id 6 for calling a global function with example usage: format_decisions(decisions) and returns: res, None