code: def check_correctness(check_program, timeout, task_id, completion_id):
      """
      Evaluates the functional correctness of a completion by running the test
      suite provided in the problem.
  
      :param completion_id: an optional completion ID so we can match
          the results later even if execution finishes asynchronously.
      """
      manager = multiprocessing.Manager()
      result = manager.list()
  
      p = multiprocessing.Process(
          target=unsafe_execute, args=(check_program, result, timeout)
      )
      p.start()
      p.join(timeout=timeout + 1)
      if p.is_alive():
          p.kill()
  
      if not result:
          result.append("timed out")
  
      return {
          "task_id": task_id,
          "passed": result[0] == "passed",
          "result": result[0],
          "completion_id": completion_id,
      }
  
imports: import contextlib
  import faulthandler
  import io
  import multiprocessing
  import os
  import platform
  import signal
  import tempfile
label_desc: Use image node_id 1 for calling a global function with example usage: check_correctness(check_program, timeout, task_id, completion_id) and returns: dict