code: def kill_command(pid, timeout=60):
      """Kill the process of pid (with a terminate signal).
      Waiting up to 60 seconds until the process is killed.
      """
      # TODO: The input argument should better be Popen rather than pid.
      if sys.platform == "win32":
          try:
              process = psutil.Process(pid=pid)
              process.send_signal(signal.CTRL_BREAK_EVENT)
          except psutil.NoSuchProcess:
              print_warning(
                  f"Tried to kill process (pid = {pid}), but the process does not exist."
              )
      else:
          cmds = ["kill", str(pid)]
          call(cmds)
      if not _wait_till_process_killed(pid, timeout):
          print_warning(
              f"One subprocess (pid = {pid}) still exists after {timeout} seconds since sending the killing signal is sent. "
              "Perhaps the shutdown of this process has hang for some reason. You might have to kill it by yourself."
          )
  
file_path: nni/nni/tools/nnictl/command_utils.py
imports: from subprocess import call, check_output
  import sys
  import os
  import time
  import signal
  import psutil
  from .common_utils import print_error, print_warning
label_desc: Use image node_id 2 for calling a global function with example usage: kill_command(pid, timeout) without return types