code: def run_in_spawned_process(func, env, *args):
      """
      Helper function to run a test in its own process.
  
      Avoids issues with Singleton- or otherwise-cached environment variable lookups in the backend.
      Adds a seed as first arg to propagate determinism.
  
      Parameters
      ----------
  
      func : function to run in a spawned process.
      env : dict of additional environment values to set temporarily in the environment before exec.
      args : args to pass to the function.
  
      Returns
      -------
      Whether the python version supports running the function as a spawned process.
  
      This routine calculates a random seed and passes it into the test as a first argument.  If the
      test uses random values, it should include an outer 'with random_seed(seed):'.  If the
      test needs to return values to the caller, consider use of shared variable arguments.
      """
      try:
          mpctx = mp.get_context("spawn")
      except:
          print(
              f"SKIP: python{sys.version_info[0]}.{sys.version_info[1]} lacks the required process fork-exec support ... ",
              file=sys.stderr,
              end="",
          )
          return False
      else:
          seed = np.random.randint(0, 1024 * 1024 * 1024)
          with environment(env):
              # Prepend seed as first arg
              p = mpctx.Process(target=func, args=(seed,) + args)
              p.start()
              p.join()
              assert (
                  p.exitcode == 0
              ), f"Non-zero exit code {p.exitcode} from {func.__name__}()."
      return True
  
imports: import sys, os, logging, functools
  import multiprocessing
  import mxnet
  import numpy
  import random
  import shutil
  from mxnet.base import MXNetError
  from mxnet.test_utils import environment
  import models
  from contextlib import contextmanager
  import pytest
  from mxnet.util import TemporaryDirectory
  import locale
label_desc: Use image node_id 8 for calling a global function with example usage: run_in_spawned_process(func, env) and returns: True, False