code: def captured_output():
      """Use this when capturing print output for tests.
  
      Example:
          >>>>    with captured_output() as (out, err):
          >>>>        method_that_prints_hello_sagemaker()
          >>>>    output = out.getvalue().strip()
          >>>>    assert output == "Hello SageMaker!"
      """
      new_out, new_err = StringIO(), StringIO()
      old_out, old_err = sys.stdout, sys.stderr
      try:
          sys.stdout, sys.stderr = new_out, new_err
          yield sys.stdout, sys.stderr
      finally:
          sys.stdout, sys.stderr = old_out, old_err
  
imports: from __future__ import absolute_import
  import sys
  from contextlib import contextmanager
  from six import StringIO
label_desc: Use image node_id 1 for calling a global function with example usage: captured_output() without return types