code: def _server_url(url: str, port: int | None) -> str:
      """ """
      port_ = f":{port}" if port is not None else ""
  
      if url.startswith("http"):
          return f"{url.rsplit(':', 1)[0]}{port_}{'/'}"
      else:
          return f"http://{url.split(':')[0]}{port_}{'/'}"
  
imports: from __future__ import annotations
  import logging
  import json
  import os
  import urllib
  from typing import TYPE_CHECKING, Any, Callable, Literal, Protocol, TypedDict, Union, cast, overload
  from uuid import uuid4
  from ..core.types import ID
  from ..util.serialization import make_id
  from ..util.warnings import warn
  from .state import curstate
label_desc: Use image node_id 15 for calling a global function with example usage: _server_url(url, port) and returns: url, port_, str, str, url, port_, str