code: def split_lines(
      fragments: Iterable[OneStyleAndTextTuple],
  ) -> Iterable[StyleAndTextTuples]:
      """
      Take a single list of (style_str, text) tuples and yield one such list for each
      line. Just like str.split, this will yield at least one item.
  
      :param fragments: Iterable of ``(style_str, text)`` or
          ``(style_str, text, mouse_handler)`` tuples.
      """
      line: StyleAndTextTuples = []
  
      for style, string, *mouse_handler in fragments:
          parts = string.split("\n")
  
          for part in parts[:-1]:
              if part:
                  line.append(
                      cast(
                          OneStyleAndTextTuple,
                          (style, part, *mouse_handler),
                      )
                  )
              yield line
              line = []
  
          line.append(
              cast(
                  OneStyleAndTextTuple,
                  (style, parts[-1], *mouse_handler),
              )
          )
  
      # Always yield the last line, even when this is an empty line. This ensures
      # that when `fragments` ends with a newline character, an additional empty
      # line is yielded. (Otherwise, there's no way to differentiate between the
      # cases where `fragments` does and doesn't end with a newline.)
      yield line
  
file_path: catboost/contrib/python/prompt-toolkit/py3/prompt_toolkit/formatted_text/utils.py
imports: from __future__ import annotations
  from typing import Iterable, cast
  from prompt_toolkit.utils import get_cwidth
  from .base import AnyFormattedText, OneStyleAndTextTuple, StyleAndTextTuples, to_formatted_text
label_desc: Use image node_id 5 for calling a global function with example usage: split_lines(fragments) without return types