code: def _install_stream_patches(cls):
      cls._old_out_write = sys.stdout.write
      cls._old_err_write = sys.stderr.write
  
      def new_out_write(data):
          cls._old_out_write(data)
          if isinstance(data, str):
              data = data.encode()
          for buffer in cls._buffer_registry.values():
              buffer.write(data)
  
      def new_err_write(data):
          cls._old_err_write(data)
          if isinstance(data, str):
              data = data.encode()
          for buffer in cls._buffer_registry.values():
              buffer.write(data)
  
      sys.stdout.write = new_out_write
      sys.stderr.write = new_err_write
  
imports: import io
  import logging
  import re
  import sys
  import time
  import weakref
  from psutil import Process, cpu_percent
  from threading import Thread
  from typing import Union
  from weakref import WeakValueDictionary
  from aim.ext.resource.configs import AIM_RESOURCE_METRIC_PREFIX
  from aim.ext.resource.log import LogLine
  from aim.ext.resource.stat import Stat
label_desc: Use image node_id 1 for calling the ResourceTracker obj's underlying member method code with example usage: obj._install_stream_patches(cls) without return types