code: def wait_for_port_available(port, timeout):
      for i in range(timeout):
          if not detect_port(port):
              return
          warnings.warn(
              "Port isn't available in {} seconds (patience: {})".format(
                  i, timeout
              ),
              RuntimeWarning,
          )
          time.sleep(1)
  
      msg = "Port {} is not available in {} seconds. Maybe the previous experiment fails to stop?".format(
          port, timeout
      )
      raise RuntimeError(msg)
  
imports: import contextlib
  import collections
  import os
  import socket
  import sys
  import subprocess
  import requests
  import time
  import yaml
  import shlex
  import warnings
label_desc: Use image node_id 21 for calling a global function with example usage: wait_for_port_available(port, timeout) without return types