code: def terminal_encoding(term):
      """Return our best guess of encoding for the given *term*."""
      if getattr(term, "encoding", None):
          return term.encoding
      import locale
  
      return locale.getpreferredencoding()
  
imports: import re
  from io import TextIOWrapper
label_desc: Use image node_id 16 for calling a global function with example usage: terminal_encoding(term) and returns: locale, term