docs: def _wait_and_kill(pid_to_wait, pids_to_kill):
    """ Helper function.
  
        Wait for a process to finish if it exists, and then try to kill a list of
        processes.
  
        Used by local_train
  
    Args:
      pid_to_wait: the process to wait for.
      pids_to_kill: a list of processes to kill after the process of pid_to_wait finishes.
    """
    # cloud workers don't have psutil
    import psutil
    if psutil.pid_exists(pid_to_wait):
      psutil.Process(pid=pid_to_wait).wait()
  
    for pid_to_kill in pids_to_kill:
      if psutil.pid_exists(pid_to_kill):
        p = psutil.Process(pid=pid_to_kill)
        p.kill()
        p.wait()