code: def _spawn(func, arg, dir):
      with NamedTemporaryFile(
          prefix="parallel_map_", dir=dir, delete=False
      ) as tmpfile:
          output_file = tmpfile.name
  
      # Make sure stdout and stderr are flushed before forking,
      # or else we may print multiple copies of the same output
      sys.stderr.flush()
      sys.stdout.flush()
      pid = os.fork()
      if pid:
          return pid, output_file
      else:
          with tracing.post_fork():
              try:
                  exit_code = 1
                  ret = func(arg)
                  with open(output_file, "wb") as f:
                      pickle.dump(
                          ret, f, protocol=pickle.HIGHEST_PROTOCOL
                      )
                  exit_code = 0
              except:
                  # we must not let any exceptions escape this function
                  # which might trigger unintended side-effects
                  traceback.print_exc()
              finally:
                  sys.stderr.flush()
                  sys.stdout.flush()
                  # we can't use sys.exit(0) here since it raises SystemExit
                  # that may have unintended side-effects (e.g. triggering
                  # finally blocks).
                  os._exit(exit_code)
  
file_path: metaflow/metaflow/multicore_utils.py
imports: import sys
  import os
  import traceback
  from itertools import islice
  from tempfile import NamedTemporaryFile
  import time
  import metaflow.tracing
label_desc: Use image node_id 1 for calling a global function with example usage: _spawn(func, arg, dir) and returns: pid,  output_file