code: def parse_ids(args):
      """Parse the arguments for nnictl stop
      1.If port is provided and id is not specified, return the id who owns the port
      2.If both port and id are provided, return the id if it owns the port, otherwise fail
      3.If there is an id specified, return the corresponding id
      4.If there is no id specified, and there is an experiment running, return the id, or return Error
      5.If the id matches an experiment, nnictl will return the id.
      6.If the id ends with ``*``, nnictl will match all ids matchs the regular
      7.If the id does not exist but match the prefix of an experiment id, nnictl will return the matched id
      8.If the id does not exist but match multiple prefix of the experiment ids, nnictl will give id information
      """
      update_experiment()
      experiments_config = Experiments()
      experiments_dict = experiments_config.get_all_experiments()
      if not experiments_dict:
          print_normal("Experiment is not running...")
          return None
      result_list = []
      running_experiment_list = []
      for key in experiments_dict.keys():
          if isinstance(experiments_dict[key], dict):
              if experiments_dict[key].get("status") != "STOPPED":
                  running_experiment_list.append(key)
          elif isinstance(experiments_dict[key], list):
              # if the config file is old version, remove the configuration from file
              experiments_config.remove_experiment(key)
      if args.all:
          return running_experiment_list
      if args.port is not None:
          for key in running_experiment_list:
              if experiments_dict[key].get("port") == args.port:
                  result_list.append(key)
          if args.id and result_list and args.id != result_list[0]:
              print_error(
                  "Experiment id and resful server port not match"
              )
              exit(1)
      elif not args.id:
          if len(running_experiment_list) > 1:
              print_error(
                  "There are multiple experiments, please set the experiment id..."
              )
              experiment_information = ""
              for key in running_experiment_list:
                  experiment_information += EXPERIMENT_DETAIL_FORMAT % (
                      key,
                      experiments_dict[key].get(
                          "experimentName", "N/A"
                      ),
                      experiments_dict[key]["status"],
                      experiments_dict[key].get("port", "N/A"),
                      experiments_dict[key].get("platform"),
                      time.strftime(
                          "%Y-%m-%d %H:%M:%S",
                          time.localtime(
                              experiments_dict[key]["startTime"] / 1000
                          ),
                      )
                      if isinstance(
                          experiments_dict[key]["startTime"], int
                      )
                      else experiments_dict[key]["startTime"],
                      time.strftime(
                          "%Y-%m-%d %H:%M:%S",
                          time.localtime(
                              experiments_dict[key]["endTime"] / 1000
                          ),
                      )
                      if isinstance(
                          experiments_dict[key]["endTime"], int
                      )
                      else experiments_dict[key]["endTime"],
                  )
              print(
                  EXPERIMENT_INFORMATION_FORMAT % experiment_information
              )
              exit(1)
          else:
              result_list = running_experiment_list
      elif args.id.endswith("*"):
          for expId in running_experiment_list:
              if expId.startswith(args.id[:-1]):
                  result_list.append(expId)
      elif args.id in running_experiment_list:
          result_list.append(args.id)
      else:
          for expId in running_experiment_list:
              if expId.startswith(args.id):
                  result_list.append(expId)
          if len(result_list) > 1:
              print_error(
                  args.id
                  + " is ambiguous, please choose "
                  + " ".join(result_list)
              )
              return None
      if not result_list and (args.id or args.port):
          print_error(
              "There are no experiments matched, please set correct experiment id or restful server port"
          )
      elif not result_list:
          print_error("There is no experiment running...")
      return result_list
  
imports: import csv
  import os
  import sys
  import json
  import time
  import shutil
  import subprocess
  from functools import cmp_to_key
  import traceback
  from datetime import datetime, timezone
  from subprocess import Popen
  from .rest_utils import rest_get, rest_delete, check_rest_server_quick, check_response
  from .url_utils import trial_jobs_url, experiment_url, trial_job_id_url, export_data_url, metric_data_url
  from .config_utils import Config, Experiments
  from .constants import NNI_HOME_DIR, EXPERIMENT_INFORMATION_FORMAT, EXPERIMENT_DETAIL_FORMAT, EXPERIMENT_MONITOR_INFO, TRIAL_MONITOR_HEAD, TRIAL_MONITOR_CONTENT, TRIAL_MONITOR_TAIL, REST_TIME_OUT
  from .common_utils import print_normal, print_error, print_warning, detect_process, get_yml_content, generate_temp_dir
  from .common_utils import print_green
  from .command_utils import check_output_command, kill_command
  from .ssh_utils import create_ssh_sftp_client, remove_remote_directory
label_desc: Use image node_id 5 for calling a global function with example usage: parse_ids(args) and returns: result_list, None, running_experiment_list, None