code: def _set_stdout_handler(_logger, stdout="raw", level="INFO"):
      level = _get_level(level)
      supported_stdout = ["none", "raw", "tqdm", "naive", "rich"]
      if stdout not in supported_stdout:
          raise ValueError(
              "stdout must in one of {}".format(supported_stdout)
          )
      # make sure to initialize _logger only once
      stream_handler = None
      _handlers = (
          logging.StreamHandler,
          TqdmLoggingHandler,
          StdoutStreamHandler,
          RichHandler,
      )
      for i, h in enumerate(_logger.handlers):
          if isinstance(h, _handlers):
              stream_handler = h
              break
      if stream_handler is not None:
          _logger.removeHandler(stream_handler)
          del stream_handler
  
      # Stream Handler
      if stdout == "raw":
          stream_handler = StdoutStreamHandler()
      elif stdout == "rich":
          stream_handler = RichHandler(
              level=level, log_time_format="[%X]"
          )
      elif stdout == "naive":
          stream_handler = logging.StreamHandler(sys.stdout)
      elif stdout == "tqdm":
          stream_handler = TqdmLoggingHandler(level)
      else:
          stream_handler = None
  
      if stream_handler is not None:
          if is_cur_env_distributed():
              stream_formatter = logging.Formatter(
                  "Rank: %(rank)s - %(message)s"
              )
          else:
              stream_formatter = logging.Formatter("%(message)s")
          stream_handler.setLevel(level)
          stream_handler.setFormatter(stream_formatter)
          _logger.addHandler(stream_handler)
  
      return stream_handler
  
imports: import logging
  import logging.config
  from logging import DEBUG, ERROR, INFO, WARNING, CRITICAL, raiseExceptions
  import os
  import sys
  import warnings
  from pathlib import Path
  from typing import Optional, Union
  from rich.logging import RichHandler
  from fastNLP.core.log.handler import StdoutStreamHandler, TqdmLoggingHandler
  from fastNLP.envs.env import FASTNLP_LOG_LEVEL, FASTNLP_GLOBAL_RANK, FASTNLP_LAUNCH_TIME, FASTNLP_BACKEND_LAUNCH
  from fastNLP.envs.distributed import is_cur_env_distributed
label_desc: Use image node_id 3 for calling a global function with example usage: _set_stdout_handler(_logger, stdout, level) and returns: stream_handler