code: def _get_favicon_string(page_icon: PageIcon) -> str:
      """Return the string to pass to the frontend to have it show
      the given PageIcon.
  
      If page_icon is a string that looks like an emoji (or an emoji shortcode),
      we return it as-is. Otherwise we use `image_to_url` to return a URL.
  
      (If `image_to_url` raises an error and page_icon is a string, return
      the unmodified page_icon string instead of re-raising the error.)
      """
  
      # Choose a random emoji.
      if page_icon == "random":
          return get_random_emoji()
  
      # If page_icon is an emoji, return it as is.
      if isinstance(page_icon, str) and is_emoji(page_icon):
          return page_icon
  
      # Fall back to image_to_url.
      try:
          return image.image_to_url(
              page_icon,
              width=-1,  # Always use full width for favicons
              clamp=False,
              channels="RGB",
              output_format="auto",
              image_id="favicon",
          )
      except Exception:
          if isinstance(page_icon, str):
              # This fall-thru handles emoji shortcode strings (e.g. ":shark:"),
              # which aren't valid filenames and so will cause an Exception from
              # `image_to_url`.
              return page_icon
          raise
  
file_path: streamlit/lib/streamlit/commands/page_config.py
imports: import random
  from textwrap import dedent
  from typing import TYPE_CHECKING, Mapping, Optional, Union, cast
  from urllib.parse import urlparse
  from typing_extensions import Final, Literal, TypeAlias
  from streamlit.elements import image
  from streamlit.errors import StreamlitAPIException
  from streamlit.proto.ForwardMsg_pb2 import ForwardMsg
  from streamlit.proto.PageConfig_pb2 import PageConfig
  from streamlit.runtime.metrics_util import gather_metrics
  from streamlit.runtime.scriptrunner import get_script_run_ctx
  from streamlit.string_util import is_emoji
  from streamlit.util import lower_clean_dict_keys
label_desc: Use image node_id 1 for calling a global function with example usage: _get_favicon_string(page_icon) and returns: get_random_emoji, page_icon, image, page_icon