code: def get_first_available_port(initial: int, final: int) -> int:
      """
      Gets the first open port in a specified range of port numbers
      Parameters:
      initial: the initial value in the range of port numbers
      final: final (exclusive) value in the range of port numbers, should be greater than `initial`
      Returns:
      port: the first open port in the range
      """
      for port in range(initial, final):
          try:
              s = socket.socket()  # create a socket object
              s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
              s.bind((LOCALHOST_NAME, port))  # Bind to the port
              s.close()
              return port
          except OSError:
              pass
      raise OSError(
          f"All ports from {initial} to {final - 1} are in use. Please close a port."
      )
  
imports: from __future__ import annotations
  import os
  import socket
  import threading
  import time
  import warnings
  from functools import partial
  from typing import TYPE_CHECKING
  import httpx
  import uvicorn
  from uvicorn.config import Config
  from gradio.exceptions import ServerFailedToStartError
  from gradio.routes import App
  from gradio.tunneling import Tunnel
  from gradio.utils import SourceFileReloader, watchfn
label_desc: Use image node_id 1 for calling a global function with example usage: get_first_available_port(initial, final) and returns: port