code: def update_tree(
      original_tree,
      dep_sentence,
      con_id,
      dep_id,
      mwt_map,
      tsurgeon_processor,
  ):
      """
      Update a tree using the mwt_map and tsurgeon to expand some MWTs
  
      Then replace the words in the con tree with the words in the dep tree
      """
      ud_words = [x.text for x in dep_sentence.words]
  
      updated_tree, operations = update_mwts_and_special_cases(
          original_tree, dep_sentence, mwt_map, tsurgeon_processor
      )
  
      # this checks number of words
      try:
          updated_tree = updated_tree.replace_words(ud_words)
      except ValueError as e:
          raise ValueError(
              "Failed to process {} {}:\nORIGINAL TREE\n{}\nUPDATED TREE\n{}\nUPDATED LEAVES\n{}\nUD TEXT\n{}\nTsurgeons applied:\n{}\n".format(
                  con_id,
                  dep_id,
                  original_tree,
                  updated_tree,
                  updated_tree.leaf_labels(),
                  ud_words,
                  "\n".join("{}".format(op) for op in operations),
              )
          ) from e
      return updated_tree
  
imports: from collections import defaultdict, deque, namedtuple
  import itertools
  import os
  import re
  import sys
  from tqdm import tqdm
  from stanza.models.constituency.tree_reader import read_trees, UnclosedTreeError, ExtraCloseTreeError
  from stanza.server import tsurgeon
  from stanza.utils.conll import CoNLL
  from stanza.utils.datasets.constituency.utils import SHARDS, write_dataset
  import stanza.utils.default_paths
label_desc: Use image node_id 10 for calling a global function with example usage: update_tree(original_tree, dep_sentence, con_id, dep_id, mwt_map, tsurgeon_processor) and returns: updated_tree