code: def _remote_jupyter_proxy_url(port: int | None) -> str:
      """Callable to configure Bokeh's show method when a proxy must be
      configured. If port is None we're asking about the URL
      for the origin header.
  
      Taken from documentation here:
  
         https://docs.bokeh.org/en/latest/docs/user_guide/output/jupyter.html#jupyterhub
  
      and made an implicit override when JUPYTER_BOKEH_EXTERNAL_URL is defined in
      a user's environment to the external hostname of the hub, e.g. https://our-hub.edu
  
      Args:
         port (int):
             random port generated by bokeh to avoid re-using recently closed ports
  
         Returns:
             str:
                 URL capable of traversing the JupyterHub proxy to return to this notebook session.
      """
      base_url = os.environ["JUPYTER_BOKEH_EXTERNAL_URL"]
      host = urllib.parse.urlparse(base_url).netloc
  
      # If port is None we're asking for the URL origin
      # so return the public hostname.
      if port is None:
          return host
  
      service_url_path = os.environ["JUPYTERHUB_SERVICE_PREFIX"]
      proxy_url_path = f"proxy/{port}"
  
      user_url = urllib.parse.urljoin(base_url, service_url_path)
      full_url = urllib.parse.urljoin(user_url, proxy_url_path)
      return full_url
  
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 16 for calling a global function with example usage: _remote_jupyter_proxy_url(port) and returns: full_url, host