code: def _select_block(str_in, start_tag, end_tag):
      """Select first block delimited by start_tag and end_tag"""
      start_pos = str_in.find(start_tag)
      if start_pos < 0:
          raise ValueError("start_tag not found")
      depth = 0
      for pos in range(start_pos, len(str_in)):
          if str_in[pos] == start_tag:
              depth += 1
          elif str_in[pos] == end_tag:
              depth -= 1
  
          if depth == 0:
              break
      sel = str_in[start_pos + 1 : pos]
      return sel
  
imports: from __future__ import print_function
  import codecs
  import gzip
  import os
  import posixpath
  import re
  import shelve
  import sys
  from io import StringIO
  from .None import sphinx_compatibility
label_desc: Use image node_id 3 for calling a global function with example usage: _select_block(str_in, start_tag, end_tag) and returns: sel