code: def clean_function_factory():
      only_speaker_text_re = re.compile(
          r"((^|\n)((ANNOUNCER|AUDIENCE MEMBERS?): .+)($|\n)|(\n|^)((([A-Z\.()\- ]+): ))|\(.+\) *)",
          re.M,
      )
      assert (
          only_speaker_text_re.sub(
              "", "AUDIENCE MEMBERS: (Chanting.) USA! USA! USA! USA!"
          )
          == ""
      )
      assert (
          only_speaker_text_re.sub(
              "", "AUDIENCE MEMBER: (Chanting.) USA! USA! USA! USA!"
          )
          == ""
      )
      assert (
          only_speaker_text_re.sub(
              "", "ANNOUNCER: (Chanting.) USA! USA! USA! USA!"
          )
          == ""
      )
      assert (
          only_speaker_text_re.sub(
              "", "TOM SMITH: (Chanting.) USA! USA! USA! USA!"
          )
          == "USA! USA! USA! USA!"
      )
      assert (
          only_speaker_text_re.sub("", "DONALD TRUMP: blah blah blah!")
          == "blah blah blah!"
      )
      assert (
          only_speaker_text_re.sub(
              "",
              "HILLARY CLINTON: (something parenthetical) blah blah blah!",
          )
          == "blah blah blah!"
      )
      assert (
          only_speaker_text_re.sub(
              "",
              "ANNOUNCER: (Chanting.) USA! USA! USA! USA!\nTOM SMITH: (Chanting.) ONLY INCLUDE THIS! ONLY KEEP THIS! \nAUDIENCE MEMBER: (Chanting.) USA! USA! USA! USA!",
          ).strip()
          == "ONLY INCLUDE THIS! ONLY KEEP THIS!"
      )
  
      def clean_document(text):
          return only_speaker_text_re.sub("", text)
  
      return clean_document
  
imports: import json
  import os
  import pkgutil
  import re
  from unittest import TestCase
  import numpy
  import pandas
  from scattertext.ParsedCorpus import ParsedCorpus
  from scattertext.CorpusFromParsedDocuments import CorpusFromParsedDocuments
  from scattertext.WhitespaceNLP import whitespace_nlp
  from scattertext.TermDocMatrixFactory import TermDocMatrixFactory
  from scattertext.test.test_TermDocMat import get_hamlet_docs, get_hamlet_snippet_binary_category
  from scattertext.test.test_corpusFromPandas import get_docs_categories
label_desc: Use image node_id 1 for calling a global function with example usage: clean_function_factory() and returns: clean_document, only_speaker_text_re