code: def patch_logger(name):
      """patch logger and give an output"""
      io_out = StringIO()
      log = logging.getLogger(name)
      handler = logging.StreamHandler(io_out)
      log.addHandler(handler)
      try:
          yield io_out
      finally:
          log.removeHandler(handler)
  
imports: import contextlib
  import logging
  import shutil
  import sys
  import tempfile
  import unittest
  from io import StringIO
  import pytest
  from xgboost import testing
  from pyspark.sql import SparkSession
  from xgboost.spark.utils import _get_default_params_from_func
label_desc: Use image node_id 2 for calling a global function with example usage: patch_logger(name) without return types