docstr: Add StreamHandler that log to stdout and stderr to the logger. INFO and lower logs are streamed to stdout
  while WARNING and higher are streamed to stderr. If the NEMO_ENV_VARNAME_REDIRECT_LOGS_TO_STDERR environment
  variable is set, all logs are sent to stderr instead.
docstr_tok: ["Add","StreamHandler","that","log","to","stdout","and","stderr","to","the","logger",".","INFO","and","lower","logs","are","streamed","to","stdout","while","WARNING","and","higher","are","streamed","to","stderr",".","If","the","NEMO_ENV_VARNAME_REDIRECT_LOGS_TO_STDERR","environment","variable","is","set",",","all","logs","are","sent","to","stderr","instead","."]
code: def add_stream_handlers(self, formatter=BaseNeMoFormatter):
      """Add StreamHandler that log to stdout and stderr to the logger. INFO and lower logs are streamed to stdout
      while WARNING and higher are streamed to stderr. If the NEMO_ENV_VARNAME_REDIRECT_LOGS_TO_STDERR environment
      variable is set, all logs are sent to stderr instead.
      """
      if self._logger is None:
          raise RuntimeError(
              "Impossible to set handlers if the Logger is not predefined"
          )
  
      # Add the output handler.
      if get_envbool(NEMO_ENV_VARNAME_REDIRECT_LOGS_TO_STDERR, False):
          self._handlers["stream_stdout"] = _logging.StreamHandler(
              sys.stderr
          )
  
      else:
          self._handlers["stream_stdout"] = _logging.StreamHandler(
              sys.stdout
          )
          self._handlers["stream_stdout"].addFilter(
              lambda record: record.levelno <= _logging.INFO
          )
  
          self._handlers["stream_stderr"] = _logging.StreamHandler(
              sys.stderr
          )
          self._handlers["stream_stderr"].addFilter(
              lambda record: record.levelno > _logging.INFO
          )
  
      self._handlers["stream_stdout"].setFormatter(formatter())
      self._logger.addHandler(self._handlers["stream_stdout"])
  
      try:
          self._handlers["stream_stderr"].setFormatter(formatter())
          self._logger.addHandler(self._handlers["stream_stderr"])
      except KeyError:
          pass
  
imports: import enum
  import logging
  import sys
  import threading
  import warnings
  from contextlib import contextmanager
  from logging.handlers import MemoryHandler
  from nemo.constants import NEMO_ENV_VARNAME_REDIRECT_LOGS_TO_STDERR, NEMO_ENV_VARNAME_TESTING
  from nemo.utils.env_var_parsing import get_envbool
  from nemo.utils.formatters.base import BaseNeMoFormatter, DebugNeMoFormatter
  from nemo.utils.get_rank import is_global_rank_zero
  from nemo.utils.metaclasses import Singleton
label_desc: Use image node_id 4 for calling the Logger obj's underlying member method code with example usage: obj.add_stream_handlers(formatter) without return types