code: def save_experiment(args):
      """save experiment data to a zip file"""
      experiments_config = Experiments()
      experiments_dict = experiments_config.get_all_experiments()
      if args.id is None:
          print_error("Please set experiment id.")
          exit(1)
      if args.id not in experiments_dict:
          print_error("Cannot find experiment {0}.".format(args.id))
          exit(1)
      if experiments_dict[args.id].get("status") != "STOPPED":
          print_error("Can only save stopped experiment!")
          exit(1)
      print_normal("Saving...")
      experiment_config = Config(
          args.id, experiments_dict[args.id]["logDir"]
      ).get_config()
      logDir = os.path.join(
          experiments_dict[args.id]["logDir"], args.id
      )
      temp_root_dir = generate_temp_dir()
  
      # Step1. Copy logDir to temp folder
      if not os.path.exists(logDir):
          print_error("logDir: %s does not exist!" % logDir)
          exit(1)
      temp_experiment_dir = os.path.join(temp_root_dir, "experiment")
      shutil.copytree(logDir, temp_experiment_dir)
  
      # Step2. Copy nnictl metadata to temp folder
      temp_nnictl_dir = os.path.join(temp_root_dir, "nnictl")
      os.makedirs(temp_nnictl_dir, exist_ok=True)
      try:
          with open(
              os.path.join(temp_nnictl_dir, ".experiment"), "w"
          ) as file:
              experiments_dict[args.id]["id"] = args.id
              json.dump(experiments_dict[args.id], file)
      except IOError:
          print_error(
              "Write file to %s failed!"
              % os.path.join(temp_nnictl_dir, ".experiment")
          )
          exit(1)
      nnictl_log_dir = os.path.join(NNI_HOME_DIR, args.id, "log")
      shutil.copytree(
          nnictl_log_dir, os.path.join(temp_nnictl_dir, args.id, "log")
      )
  
      # Step3. Copy code dir
      if args.saveCodeDir:
          temp_code_dir = os.path.join(temp_root_dir, "code")
          shutil.copytree(
              experiment_config["trial"]["codeDir"], temp_code_dir
          )
  
      # Step4. Copy searchSpace file
      search_space_path = experiment_config.get("searchSpacePath")
      if search_space_path:
          if not os.path.exists(search_space_path):
              print_warning(
                  "search space %s does not exist!" % search_space_path
              )
          else:
              temp_search_space_dir = os.path.join(
                  temp_root_dir, "searchSpace"
              )
              os.makedirs(temp_search_space_dir, exist_ok=True)
              search_space_name = os.path.basename(search_space_path)
              shutil.copyfile(
                  search_space_path,
                  os.path.join(
                      temp_search_space_dir, search_space_name
                  ),
              )
  
      # Step5. Archive folder
      zip_package_name = "nni_experiment_%s" % args.id
      if args.path:
          os.makedirs(args.path, exist_ok=True)
          zip_package_name = os.path.join(args.path, zip_package_name)
      shutil.make_archive(zip_package_name, "zip", temp_root_dir)
      print_normal("Save to %s.zip success!" % zip_package_name)
  
      # Step5. Cleanup temp data
      shutil.rmtree(temp_root_dir)
  
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 34 for calling a global function with example usage: save_experiment(args) without return types