code: def detect_port(port):
      """Detect if the port is used, return True if the port is used"""
      socket_test = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
      try:
          socket_test.connect(("127.0.0.1", int(port)))
          socket_test.close()
          return True
      except:
          return False
  
file_path: nni/test/training_service/nnitest/remote_docker.py
imports: import os
  import argparse
  from subprocess import check_output, check_call
  import socket
  import random
  import re
label_desc: Use image node_id 1 for calling a global function with example usage: detect_port(port) and returns: True, False