code: def main() -> None:
      pid_file = Path(sys.argv[1], "trial_keeper.pid")
  
      try:
          pid = int(pid_file.read_text())
      except Exception:
          _exit_with_result(
              {
                  "alive": False,
                  "reason": f"Cannot read pid file {pid_file}",
              }
          )
  
      try:
          proc = psutil.Process(pid)
      except Exception:
          _exit_with_result(
              {"alive": False, "reason": f"Process {pid} not found"}
          )
  
      if "nni" in " ".join(proc.cmdline()):
          _exit_with_result({"alive": True})
      else:
          _exit_with_result(
              {"alive": False, "reason": f"Process {pid} is not nni"}
          )
  
imports: import json
  from pathlib import Path
  import sys
  from typing import Any, NoReturn
  import psutil
label_desc: Use image node_id 1 for calling a global function with example usage: main() without return types