code: def mytestFunction(insum=0):
      """
      Run a multiprocessing job and spawn child processes.
      """
  
      # need to import here since this is executed as an external process
      import multiprocessing
      import os
      import tempfile
      import time
  
      numberOfThreads = 2
  
      # list of processes
      t = [None] * numberOfThreads
  
      # list of alive flags
      a = [None] * numberOfThreads
  
      # list of tempFiles
      f = [None] * numberOfThreads
  
      def dummyFunction(filename):
          """
          This function writes the value 45 to the given filename.
          """
          j = 0
          for i in range(0, 10):
              j += i
  
          # j is now 45 (0+1+2+3+4+5+6+7+8+9)
  
          with open(filename, "w") as f:
              f.write(str(j))
  
      for n in range(numberOfThreads):
          # mark thread as alive
          a[n] = True
  
          # create a temp file to use as the data exchange container
          tmpFile = tempfile.mkstemp(".txt", "test_engine_")[1]
          f[n] = tmpFile  # keep track of the temp file
          t[n] = multiprocessing.Process(
              target=dummyFunction, args=(tmpFile,)
          )
          # fire up the job
          t[n].start()
  
      # block until all processes are done
      allDone = False
      while not allDone:
          time.sleep(1)
  
          for n in range(numberOfThreads):
              a[n] = t[n].is_alive()
  
          if not any(a):
              # if no thread is alive
              allDone = True
  
      # here, all processes are done
  
      # read in all temp files and sum them up
      total = insum
      for ff in f:
          with open(ff) as fd:
              total += int(fd.read())
          os.remove(ff)
  
      return total
  
file_path: nipype/nipype/pipeline/plugins/tests/test_legacymultiproc_nondaemon.py
imports: import os
  import sys
  from tempfile import mkdtemp
  from shutil import rmtree
  import pytest
  import nipype.pipeline.engine
  from nipype.interfaces.utility import Function
label_desc: Use image node_id 1 for calling a global function with example usage: mytestFunction(insum) and returns: total