code: def check_parent_alive(task: "subprocess.Popen") -> None:
      orig_parent_id = os.getppid()
      while True:
          if os.getppid() != orig_parent_id:
              clean_and_terminate(task)
              break
          time.sleep(0.5)
  
file_path: spark/python/pyspark/ml/torch/torch_run_process_wrapper.py
imports: import os
  import signal
  import subprocess
  import sys
  import threading
  import time
  from typing import Any
label_desc: Use image node_id 2 for calling a global function with example usage: check_parent_alive(task) without return types