code: def _format_syntax_error_message(exception: SyntaxError) -> str:
      """Returns a nicely formatted SyntaxError message that emulates
      what the Python interpreter outputs, e.g.:
  
      > File "raven.py", line 3
      >   st.write('Hello world!!'))
      >                            ^
      > SyntaxError: invalid syntax
  
      """
      if exception.text:
          if exception.offset is not None:
              caret_indent = " " * max(exception.offset - 1, 0)
          else:
              caret_indent = ""
  
          return (
              'File "%(filename)s", line %(lineno)s\n'
              "  %(text)s\n"
              "  %(caret_indent)s^\n"
              "%(errname)s: %(msg)s"
              % {
                  "filename": exception.filename,
                  "lineno": exception.lineno,
                  "text": exception.text.rstrip(),
                  "caret_indent": caret_indent,
                  "errname": type(exception).__name__,
                  "msg": exception.msg,
              }
          )
      # If a few edge cases, SyntaxErrors don't have all these nice fields. So we
      # have a fall back here.
      # Example edge case error message: encoding declaration in Unicode string
      return str(exception)
  
file_path: streamlit/lib/streamlit/elements/exception.py
imports: import os
  import traceback
  from typing import TYPE_CHECKING, List, Optional, cast
  from typing_extensions import Final
  import streamlit
  from streamlit.errors import MarkdownFormattedException, StreamlitAPIException, StreamlitAPIWarning, StreamlitDeprecationWarning, UncaughtAppException
  from streamlit.logger import get_logger
  from streamlit.proto.Exception_pb2 import Exception
  from streamlit.runtime.metrics_util import gather_metrics
label_desc: Use image node_id 2 for calling a global function with example usage: _format_syntax_error_message(exception) and returns: str, unknown