code: def shorten(text, width, **kwargs):
      """Collapse and truncate the given text to fit in the given width.
  
      The text first has its whitespace collapsed.  If it then fits in
      the *width*, it is returned as is.  Otherwise, as many words
      as possible are joined and then the placeholder is appended::
  
          >>> textwrap.shorten("Hello  world!", width=12)
          'Hello world!'
          >>> textwrap.shorten("Hello  world!", width=11)
          'Hello [...]'
      """
      w = TextWrapper(width=width, max_lines=1, **kwargs)
      return w.fill(" ".join(text.strip().split()))
  
file_path: catboost/contrib/tools/python3/src/Lib/textwrap.py
imports: import re
label_desc: Use image node_id 3 for calling a global function with example usage: shorten(text, width) and returns: w