code: def collect_stdout(stream):
      sys.stdout.flush()
      old = sys.stdout
      sys.stdout = stream
      yield stream
      stream.flush()
      sys.stdout = old
  
file_path: catboost/tools/black_linter/bin/__main__.py
imports: import contextlib
  import io
  import logging
  import os
  import sys
  import time
  from pathlib import Path
  import yalibrary.term.console
  from library.python.testing.custom_linter_util import linter_params, reporter
  import black
  import black.files
  import black.report
  import black.mode
label_desc: Use image node_id 1 for calling a global function with example usage: collect_stdout(stream) without return types