code: def expand_user(path):
      """Expand '~'-style usernames in strings.
  
      This is similar to :func:`os.path.expanduser`, but it computes and returns
      extra information that will be useful if the input was being used in
      computing completions, and you wish to return the completions with the
      original '~' instead of its expanded value.
  
      Parameters
      ----------
      path : str
        String to be expanded.  If no ~ is present, the output is the same as the
        input.
  
      Returns
      -------
      newpath : str
        Result of ~ expansion in the input path.
      tilde_expand : bool
        Whether any expansion was performed or not.
      tilde_val : str
        The value that ~ was replaced with.
      """
      # Default values
      tilde_expand = False
      tilde_val = ""
      newpath = path
  
      if path.startswith("~"):
          tilde_expand = True
          rest = len(path) - 1
          newpath = os.path.expanduser(path)
          if rest:
              tilde_val = newpath[:-rest]
          else:
              tilde_val = newpath
  
      return newpath, tilde_expand, tilde_val
  
imports: from __future__ import print_function
  import __main__
  import glob
  import inspect
  import itertools
  import keyword
  import os
  import re
  import sys
  import unicodedata
  import string
  import warnings
  from traitlets.config.configurable import Configurable
  from IPython.core.error import TryNext
  from IPython.core.inputsplitter import ESC_MAGIC
  from IPython.core.latex_symbols import latex_symbols, reverse_latex_symbol
  from IPython.utils import generics
  from IPython.utils.decorators import undoc
  from IPython.utils.dir2 import dir2, get_real_method
  from IPython.utils.process import arg_split
  from IPython.utils.py3compat import builtin_mod, string_types, PY3, cast_unicode_py2
  from traitlets import Bool, Enum, observe
label_desc: Use image node_id 3 for calling a global function with example usage: expand_user(path) and returns: newpath,  tilde_expand,  tilde_val