code: def _update_notebook_url_from_env(
      notebook_url: str | ProxyUrlFunc,
  ) -> str | ProxyUrlFunc:
      """If the environment variable ``JUPYTER_BOKEH_EXTERNAL_URL`` is defined, returns a function which
      generates URLs which can traverse the JupyterHub proxy.  Otherwise returns ``notebook_url`` unmodified.
  
      A warning is issued if ``notebook_url`` is not the default and
      ``JUPYTER_BOKEH_EXTERNAL_URL`` is also defined since setting the
      environment variable makes specifying ``notebook_url`` irrelevant.
  
      Args:
         notebook_url (str | ProxyUrlFunc):
            Either a URL string which defaults or a function that given a port
            number will generate a URL suitable for traversing the JupyterHub proxy.
  
      Returns:
         str | ProxyUrlFunc
            Either a URL string or a function that generates a URL string given a port number.  The
            latter function may be user supplied as the input parameter or defined internally by Bokeh
            when ``JUPYER_BOKEH_EXTERNAL_URL`` is set.
  
      """
      if os.environ.get("JUPYTER_BOKEH_EXTERNAL_URL"):
          if notebook_url != DEFAULT_JUPYTER_URL:
              log.warning(
                  "Environment var 'JUPYTER_BOKEH_EXTERNAL_URL' is defined. Ignoring 'notebook_url' parameter."
              )
          return _remote_jupyter_proxy_url
      else:
          return notebook_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 17 for calling a global function with example usage: _update_notebook_url_from_env(notebook_url) and returns: _remote_jupyter_proxy_url, notebook_url