code: def format_filename(filename, shorten=False):
      """Formats a filename for user display.  The main purpose of this
      function is to ensure that the filename can be displayed at all.  This
      will decode the filename to unicode if necessary in a way that it will
      not fail.  Optionally, it can shorten the filename to not include the
      full path to the filename.
  
      :param filename: formats a filename for UI display.  This will also convert
                       the filename into unicode without failing.
      :param shorten: this optionally shortens the filename to strip of the
                      path that leads up to it.
      """
      if shorten:
          filename = os.path.basename(filename)
      return filename_to_ui(filename)
  
imports: import os
  import sys
  from ._compat import _default_text_stderr
  from ._compat import _default_text_stdout
  from ._compat import auto_wrap_for_ansi
  from ._compat import binary_streams
  from ._compat import filename_to_ui
  from ._compat import get_filesystem_encoding
  from ._compat import get_streerror
  from ._compat import is_bytes
  from ._compat import open_stream
  from ._compat import PY2
  from ._compat import should_strip_ansi
  from ._compat import string_types
  from ._compat import strip_ansi
  from ._compat import text_streams
  from ._compat import text_type
  from ._compat import WIN
  from .globals import resolve_color_default
label_desc: Use image node_id 10 for calling a global function with example usage: format_filename(filename, shorten) and returns: filename_to_ui