code: def set_monitor(auto_exit, time_interval, port=None, pid=None):
      """set the experiment monitor engine"""
      while True:
          try:
              if sys.platform == "win32":
                  os.system("cls")
              else:
                  os.system("clear")
              update_experiment()
              show_experiment_info()
              if auto_exit:
                  status = get_experiment_status(port)
                  if status in ["DONE", "ERROR", "STOPPED"]:
                      print_normal(
                          "Experiment status is {0}.".format(status)
                      )
                      print_normal("Stopping experiment...")
                      kill_command(pid)
                      print_normal("Stop experiment success.")
                      exit(0)
              time.sleep(time_interval)
          except KeyboardInterrupt:
              if auto_exit:
                  print_normal("Stopping experiment...")
                  kill_command(pid)
                  print_normal("Stop experiment success.")
              else:
                  print_normal("Exiting...")
              exit(0)
          except Exception as exception:
              print_error(exception)
              exit(1)
  
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 30 for calling a global function with example usage: set_monitor(auto_exit, time_interval, port, pid) without return types