code: def stop_experiment_test(args):
      config_file = args.config
      """Test `nnictl stop` command, including `nnictl stop exp_id` and `nnictl stop all`.
      Simple `nnictl stop` is not tested here since it is used in all other test code"""
      subprocess.run(
          [
              "nnictl",
              "create",
              "--config",
              config_file,
              "--port",
              "8080",
          ],
          check=True,
      )
      subprocess.run(
          [
              "nnictl",
              "create",
              "--config",
              config_file,
              "--port",
              "8888",
          ],
          check=True,
      )
      subprocess.run(
          [
              "nnictl",
              "create",
              "--config",
              config_file,
              "--port",
              "8989",
          ],
          check=True,
      )
      subprocess.run(
          [
              "nnictl",
              "create",
              "--config",
              config_file,
              "--port",
              "8990",
          ],
          check=True,
      )
  
      # test cmd 'nnictl stop id`
      experiment_id = get_experiment_id(EXPERIMENT_URL)
      proc = subprocess.run(["nnictl", "stop", experiment_id])
      assert (
          proc.returncode == 0
      ), "`nnictl stop %s` failed with code %d" % (
          experiment_id,
          proc.returncode,
      )
      wait_for_port_available(8080, 10)
      assert not detect_port(8080), (
          "`nnictl stop %s` failed to stop experiments" % experiment_id
      )
  
      # test cmd `nnictl stop --port`
      proc = subprocess.run(["nnictl", "stop", "--port", "8990"])
      assert (
          proc.returncode == 0
      ), "`nnictl stop %s` failed with code %d" % (
          experiment_id,
          proc.returncode,
      )
      wait_for_port_available(8990, 10)
      assert not detect_port(8990), (
          "`nnictl stop %s` failed to stop experiments" % experiment_id
      )
  
      # test cmd `nnictl stop --all`
      proc = subprocess.run(["nnictl", "stop", "--all"])
      assert proc.returncode == 0, (
          "`nnictl stop --all` failed with code %d" % proc.returncode
      )
      wait_for_port_available(8888, 10)
      wait_for_port_available(8989, 10)
      assert not detect_port(8888) and not detect_port(
          8989
      ), "`nnictl stop --all` failed to stop experiments"
  
file_path: nni/test/training_service/nnitest/naive_test.py
imports: import sys
  import os.path
  import argparse
  import json
  import subprocess
  import sys
  import time
  import traceback
  from utils import is_experiment_done, get_experiment_id, get_nni_log_path, read_last_line, remove_files, setup_experiment, detect_port, wait_for_port_available
  from utils import GREEN, RED, CLEAR, EXPERIMENT_URL
label_desc: Use image node_id 2 for calling a global function with example usage: stop_experiment_test(args) without return types