code: def split_blocks(lines):
      """Read the lines of a doc file and group them by blocks."""
      blocks = []
      block_type = None
      current_block = []
      i = 0
  
      def _move_to_next_non_empty_line(i):
          while i < len(lines) and len(lines[i]) == 0:
              i += 1
          return i
  
      def _build_block(blocks, current_block, block_type):
          if len(current_block) > 0:
              while len(current_block[-1]) == 0:
                  current_block = current_block[:-1]
              blocks.append(("\n".join(current_block), block_type))
          return blocks, []
  
      # Ignore everything before the main title (copyright header)
      while _re_title.search(lines[i]) is None:
          i += 1
  
      while i < len(lines):
          line = lines[i]
          if _re_title.search(line) is not None:
              blocks, current_block = _build_block(
                  blocks, current_block, "prose"
              )
              blocks.append((line, "title"))
              i += 1
              i = _move_to_next_non_empty_line(i)
          elif _re_block.search(line) is not None:
              blocks, current_block = _build_block(
                  blocks, current_block, "prose"
              )
              block_type = _re_block.search(line).groups()[0]
              if _re_block_lang.search(line):
                  block_type += (
                      " " + _re_block_lang.search(line).groups()[0]
                  )
              i += 1
              i = _move_to_next_non_empty_line(i)
              indent = _re_indent.search(lines[i]).groups()[0]
              if len(indent) > 0:
                  while i < len(lines) and (
                      lines[i].startswith(indent) or len(lines[i]) == 0
                  ):
                      current_block.append(lines[i])
                      i += 1
              blocks, current_block = _build_block(
                  blocks, current_block, block_type
              )
          elif _re_anchor_section.search(line):
              blocks, current_block = _build_block(
                  blocks, current_block, "prose"
              )
              blocks.append((line, "anchor"))
              i += 1
              i = _move_to_next_non_empty_line(i)
          else:
              current_block.append(line)
              i += 1
      blocks, current_block = _build_block(
          blocks, current_block, "prose"
      )
      return blocks
  
imports: import nbformat
  import os
  import re
  import shutil
label_desc: Use image node_id 1 for calling a global function with example usage: split_blocks(lines) and returns: blocks, i, blocks,  list