code: def capture_output():
      import sys
      from io import StringIO
  
      oldout, olderr = sys.stdout, sys.stderr
      try:
          out = [StringIO(), StringIO()]
          sys.stdout, sys.stderr = out
          yield out
      finally:
          sys.stdout, sys.stderr = oldout, olderr
          out[0] = out[0].getvalue()
          out[1] = out[1].getvalue()
  
file_path: nilearn/nilearn/_utils/tests/test_logger.py
imports: import contextlib
  from sklearn.base import BaseEstimator
  from nilearn._utils.logger import log
label_desc: Use image node_id 1 for calling a global function with example usage: capture_output() without return types