code: def split_mwe(tree, pipeline):
      words = list(tree.leaf_labels())
      found = False
      for idx, word in enumerate(words[:-3]):
          if (
              word == words[idx + 1]
              and word == words[idx + 2]
              and word == words[idx + 3]
          ):
              raise ValueError("Oh no, 4 consecutive words")
  
      for idx, word in enumerate(words[:-2]):
          if word == words[idx + 1] and word == words[idx + 2]:
              doc = pipeline(word)
              assert len(doc.sentences) == 1
              if len(doc.sentences[0].words) != 3:
                  raise RuntimeError(
                      "Word {} not tokenized into 3 parts... thought all 3 part words were handled!".format(
                          word
                      )
                  )
              words[idx] = doc.sentences[0].words[0].text
              words[idx + 1] = doc.sentences[0].words[1].text
              words[idx + 2] = doc.sentences[0].words[2].text
              found = True
  
      for idx, word in enumerate(words[:-1]):
          if word == words[idx + 1]:
              if word in BIWORD_SPLITS:
                  first_word = BIWORD_SPLITS[word][0]
                  second_word = BIWORD_SPLITS[word][1]
              elif CAP_BIWORD.match(word):
                  first_word, second_word = word.split("_")
              else:
                  doc = pipeline(word)
                  assert len(doc.sentences) == 1
                  if len(doc.sentences[0].words) == 2:
                      first_word = doc.sentences[0].words[0].text
                      second_word = doc.sentences[0].words[1].text
                  else:
                      if word not in UNKNOWN_SPLITS:
                          UNKNOWN_SPLITS.add(word)
                          print(
                              "Could not figure out how to split {}\n  {}\n  {}".format(
                                  word, " ".join(words), tree
                              )
                          )
                      continue
  
              words[idx] = first_word
              words[idx + 1] = second_word
              found = True
  
      if found:
          tree = tree.replace_words(words)
      return tree
  
file_path: stanza/stanza/utils/datasets/constituency/convert_it_turin.py
imports: import glob
  import os
  import re
  import sys
  import stanza
  from stanza.models.constituency import parse_tree
  from stanza.models.constituency import tree_reader
label_desc: Use image node_id 2 for calling a global function with example usage: split_mwe(tree, pipeline) and returns: tree