code: def split_code_and_text_blocks(source_file):
      """Return list with source file separated into code and text blocks.
  
      Returns
      -------
      file_conf : dict
          File-specific settings given in comments as:
          # sphinx_gallery_<name> = <value>
      blocks : list of (label, content)
          List where each element is a tuple with the label ('text' or 'code'),
          and content string of block.
      """
      docstring, rest_of_content, lineno = get_docstring_and_rest(
          source_file
      )
      blocks = [("text", docstring, 1)]
  
      file_conf = extract_file_config(rest_of_content)
  
      pattern = re.compile(
          r"(?P<header_line>^#{20,}.*)\s(?P<text_content>(?:^#.*\s)*)",
          flags=re.M,
      )
      sub_pat = re.compile("^#", flags=re.M)
  
      pos_so_far = 0
      for match in re.finditer(pattern, rest_of_content):
          code_block_content = rest_of_content[
              pos_so_far : match.start()
          ]
          if code_block_content.strip():
              blocks.append(("code", code_block_content, lineno))
          lineno += code_block_content.count("\n")
  
          lineno += 1  # Ignored header line of hashes.
          text_content = match.group("text_content")
          text_block_content = dedent(
              re.sub(sub_pat, "", text_content)
          ).lstrip()
          if text_block_content.strip():
              blocks.append(("text", text_block_content, lineno))
          lineno += text_content.count("\n")
  
          pos_so_far = match.end()
  
      remaining_content = rest_of_content[pos_so_far:]
      if remaining_content.strip():
          blocks.append(("code", remaining_content, lineno))
  
      return file_conf, blocks
  
imports: from __future__ import division, absolute_import, print_function
  import ast
  import re
  from textwrap import dedent
label_desc: Use image node_id 3 for calling a global function with example usage: split_code_and_text_blocks(source_file) and returns: file_conf,  blocks