code: def subprocess_run_helper(func, *args, timeout, extra_env=None):
      """
      Run a function in a sub-process.
  
      Parameters
      ----------
      func : function
          The function to be run.  It must be in a module that is importable.
      *args : str
          Any additional command line arguments to be passed in
          the first argument to ``subprocess.run``.
      extra_env : dict[str, str]
          Any additional environment variables to be set for the subprocess.
      """
      target = func.__name__
      module = func.__module__
      proc = subprocess_run_for_testing(
          [
              sys.executable,
              "-c",
              f"from {module} import {target}; {target}()",
              *args,
          ],
          env={
              **os.environ,
              "SOURCE_DATE_EPOCH": "0",
              **(extra_env or {}),
          },
          timeout=timeout,
          check=True,
          stdout=subprocess.PIPE,
          stderr=subprocess.PIPE,
          text=True,
      )
      return proc
  
file_path: catboost/contrib/python/matplotlib/py3/matplotlib/testing/__init__.py
imports: from pathlib import Path
  from tempfile import TemporaryDirectory
  import locale
  import logging
  import os
  import subprocess
  import sys
  import matplotlib
  from matplotlib import _api
label_desc: Use image node_id 5 for calling a global function with example usage: subprocess_run_helper(func) and returns: proc