code: def localhost_has_free_port(port: int) -> bool:
      """Checks if the port is free on localhost.
  
      Args:
          port (int): The port which will be checked.
  
      Returns:
          bool: True if port is free, else False.
      """
      sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
      is_success = sock.connect_ex(("localhost", port))
      return True if is_success else False
  
imports: import os
  import platform
  import socket
  import subprocess
  import sys
  from typing import Dict, List, Union
  import lazycluster.settings
  from .utils import Environment
label_desc: Use image node_id 6 for calling a global function with example usage: localhost_has_free_port(port) and returns: unknown