code: def segment(page_xml, include_interlinks=False):
      """Parse the content inside a page tag
  
      Parameters
      ----------
      page_xml : str
          Content from page tag.
  
      include_interlinks : bool
          Whether or not interlinks should be parsed.
  
      Returns
      -------
      (str, list of (str, str), (Optionally) list of (str, str))
          Structure contains (title, [(section_heading, section_content), ...],
          (Optionally) [(interlink_article, interlink_text), ...]).
  
      """
      elem = ElementTree.fromstring(page_xml)
      filter_namespaces = ("0",)
      namespace = get_namespace(elem.tag)
      ns_mapping = {"ns": namespace}
      text_path = "./{%(ns)s}revision/{%(ns)s}text" % ns_mapping
      title_path = "./{%(ns)s}title" % ns_mapping
      ns_path = "./{%(ns)s}ns" % ns_mapping
      lead_section_heading = "Introduction"
      top_level_heading_regex = r"\n==[^=].*[^=]==\n"
      top_level_heading_regex_capture = r"\n==([^=].*[^=])==\n"
  
      title = elem.find(title_path).text
      text = elem.find(text_path).text
      ns = elem.find(ns_path).text
      if ns not in filter_namespaces:
          text = None
  
      if text is not None:
          if include_interlinks:
              interlinks = find_interlinks(text)
          section_contents = re.split(top_level_heading_regex, text)
          section_headings = [lead_section_heading] + re.findall(
              top_level_heading_regex_capture, text
          )
          section_headings = [
              heading.strip() for heading in section_headings
          ]
          assert len(section_contents) == len(section_headings)
      else:
          interlinks = []
          section_contents = []
          section_headings = []
  
      section_contents = [
          filter_wiki(section_content)
          for section_content in section_contents
      ]
      sections = list(zip(section_headings, section_contents))
  
      if include_interlinks:
          return title, sections, interlinks
      else:
          return title, sections
  
file_path: gensim/gensim/scripts/segment_wiki.py
imports: import argparse
  import json
  import logging
  import multiprocessing
  import re
  import sys
  from xml.etree import ElementTree
  from functools import partial
  from gensim.corpora.wikicorpus import IGNORED_NAMESPACES, WikiCorpus, filter_wiki, find_interlinks, get_namespace, utils
  import gensim.utils
label_desc: Use image node_id 4 for calling a global function with example usage: segment(page_xml, include_interlinks) and returns: title,  sections,  interlinks, title,  sections