code: def init_logger(
      filename: str,
      log_level: Optional[str],
      enabled: bool = True,
      saved_dir="saved/",
  ):
      """
      A logger that can show a message on standard output and write it into the
      file named `filename` simultaneously.
      All the message that you want to log MUST be str.
  
      Args:
          filename: The filename of current experiment.
          log_level: Log log_level of loggers in `logging` module.
          enabled: (Default = True) False to throttle logging output down.
          saved_dir: (Default = './log/') Directory of log files.
  
      Example:
          >>> init_logger("filename", "warning", disabled=True)
          >>> logger = logging.getLogger(__name__)
          >>> logger.debug("train_state")
          >>> logger.info("train_result")
          >>> logger.warning("Warning!")
          Warning!
      """
      saved_dir_name = os.path.dirname(saved_dir)
      ensure_dir(saved_dir_name)
      saved_train_dir = os.path.join(saved_dir_name, filename)
      ensure_dir(saved_train_dir)
      log_filename = "project.log"
      log_filepath = os.path.join(saved_train_dir, log_filename)
  
      if log_level is None:
          log_level = "warning"
      log_level = getattr(logging, log_level.upper())
  
      file_handler = logging.FileHandler(log_filepath)
      file_handler.setLevel(log_level)
      file_handler.setFormatter(ColorFormatter("file"))
  
      stream_handler = logging.StreamHandler()
      stream_handler.setLevel(log_level)
      stream_handler.setFormatter(ColorFormatter("stream"))
  
      logging.basicConfig(
          level=log_level, handlers=[file_handler, stream_handler]
      )
      textbox_logger = get_logger("textbox")
      textbox_logger.setLevel(log_level)
  
file_path: TextBox/textbox/utils/logger.py
imports: import logging
  import os
  from accelerate.logging import get_logger
  from textbox.utils.utils import ensure_dir
  from collections import defaultdict
  from colorama import init, Fore, Style
  from typing import Optional
label_desc: Use image node_id 1 for calling a global function with example usage: init_logger(filename, log_level, enabled, saved_dir) without return types