code: def _display_jupyter(
      port, height, proxy_url, open_in_new_tab, ui_params: RenderConfig
  ):
      """Display the LIT UI in jupyter.
  
      Args:
        port: The port the LIT server is running on.
        height: The height of the LIT UI in pixels.
        proxy_url: Optional proxy URL, if using in a notebook with a server proxy.
            If not provided, LIT also checks to see if the environment variable
            LIT_PROXY_URL is set, and if so, it uses that value as the proxy URL.
        open_in_new_tab: Whether to show the UI in a new tab instead of in the
          output cell.
        ui_params: RenderConfig of options for the LIT UI.
      """
  
      # Add height to jupyter output_scroll div to fully contain LIT UI.
      output_scroll_height = height + 10
  
      params = ui_params.get_query_str()
  
      frame_id = "lit-frame-{:08x}".format(random.getrandbits(64))
      if open_in_new_tab:
          shell = """
        <a href="javascript:void(0);" id="%HTML_ID%"></a>
        <script>
          (function() {
            const urlStr = %URL% + '%PARAMS%'
            const url = new URL(urlStr, window.location);
            const port = %PORT%;
            if (port) {
              url.port = port;
            }
            const a = document.getElementById(%JSON_ID%);
            a.innerHTML = url;
            a.onclick = (e) => window.open(url, "_blank");
            window.open(url, "_blank");
          })();
        </script>
      """
      else:
          shell = """
        <style>div.output_scroll { height: %SCROLL_HEIGHT%px; }</style>
        <iframe id='%HTML_ID%' width='100%' height='%HEIGHT%' frameborder='0'>
        </iframe>
        <script>
          (function() {
            const frame = document.getElementById(%JSON_ID%);
            const urlStr = %URL% + '%PARAMS%'
            const url = new URL(urlStr, window.location);
            const port = %PORT%;
            if (port) {
              url.port = port;
            }
            frame.src = url;
          })();
        </script>
      """
  
      if proxy_url is None:
          proxy_url = os.environ.get("LIT_PROXY_URL")
  
      if proxy_url is not None:
          # Allow %PORT% in proxy_url.
          proxy_url = proxy_url.replace("%PORT%", "%d" % port)
          replacements = [
              ("%HTML_ID%", html.escape(frame_id, quote=True)),
              ("%JSON_ID%", json.dumps(frame_id)),
              ("%HEIGHT%", "%d" % height),
              ("%SCROLL_HEIGHT%", "%d" % output_scroll_height),
              ("%PORT%", "0"),
              ("%URL%", json.dumps(proxy_url)),
              ("%PARAMS%", "%s" % params),
          ]
      else:
          replacements = [
              ("%HTML_ID%", html.escape(frame_id, quote=True)),
              ("%JSON_ID%", json.dumps(frame_id)),
              ("%HEIGHT%", "%d" % height),
              ("%SCROLL_HEIGHT%", "%d" % output_scroll_height),
              ("%PORT%", "%d" % port),
              ("%URL%", json.dumps("/")),
              ("%PARAMS%", "%s" % params),
          ]
  
      for k, v in replacements:
          shell = shell.replace(k, v)
  
      iframe = display.HTML(shell)
      display.display(iframe)
  
imports: from collections.abc import Sequence
  import html
  import json
  import os
  import pathlib
  import random
  from typing import cast, Optional
  import urllib.parse
  import attr
  from IPython import display
  from lit_nlp import dev_server
  from lit_nlp import server_config
  from lit_nlp.api import layout
  from lit_nlp.lib import wsgi_serving
label_desc: Use image node_id 2 for calling a global function with example usage: _display_jupyter(port, height, proxy_url, open_in_new_tab, ui_params) without return types