code: def get_available_host_port():
      
      # Only import adb module if needed.
      from mobly.controllers.android_device_lib import adb
      for _ in range(MAX_PORT_ALLOCATION_RETRY):
          port = portpicker.PickUnusedPort()
          # Make sure adb is not using this port so we don't accidentally
          # interrupt ongoing runs by trying to bind to the port.
          if port not in adb.list_occupied_adb_ports():
              return port
      raise Error('Failed to find available port after {} retries'.format(
          MAX_PORT_ALLOCATION_RETRY))
docs: Gets a host port number available for adb forward.
  
      Returns:
          An integer representing a port number on the host available for adb
          forward.
  
      Raises:
          Error: when no port is found after MAX_PORT_ALLOCATION_RETRY times.