code: def _shrink(s: str, style: StyleCode = Text.value, limit: int = 80):
      s = s.replace("\r", "")
      lines = s.split("\n")
  
      res = []
      length = 0
      for line in lines:
          if len(res) > 0:
              res.append(("\\n", Text.subtle))
          if len(line) + length < limit:
              res.append((line, style))
              length += len(line)
          else:
              res.append((line[: limit - length], style))
              res.append((" ...", Text.warning))
              break
  
      return res
  
imports: import collections
  import math
  from typing import TYPE_CHECKING, List, Tuple
  from labml.internal.util.colors import StyleCode
  from ....logger import Text
label_desc: Use image node_id 9 for calling a global function with example usage: _shrink(s, style, limit) and returns: res