code: def process_sentence(sentence, mwt_dict=None):
      sent = []
      i = 0
      for tok, p, position_info in sentence:
          expansion = None
          if (p == 3 or p == 4) and mwt_dict is not None:
              # MWT found, (attempt to) expand it!
              if tok in mwt_dict:
                  expansion = mwt_dict[tok][0]
              elif tok.lower() in mwt_dict:
                  expansion = mwt_dict[tok.lower()][0]
          if expansion is not None:
              sent.append({ID: (i + 1, i + len(expansion)), TEXT: tok})
              if position_info is not None:
                  sent[-1][START_CHAR] = position_info[0]
                  sent[-1][END_CHAR] = position_info[1]
              for etok in expansion:
                  sent.append({ID: (i + 1,), TEXT: etok})
                  i += 1
          else:
              if len(tok) <= 0:
                  continue
              sent.append({ID: (i + 1,), TEXT: tok})
              if position_info is not None:
                  sent[-1][START_CHAR] = position_info[0]
                  sent[-1][END_CHAR] = position_info[1]
              if p == 3 or p == 4:  # MARK
                  sent[-1][MISC] = "MWT=Yes"
              i += 1
      return sent
  
imports: from collections import Counter
  from copy import copy
  import json
  import numpy
  import re
  import logging
  import os
  from torch.utils.data import DataLoader
  import stanza.utils.default_paths
  from stanza.models.common.utils import ud_scores, harmonic_mean
  from stanza.models.common.doc import Document
  from stanza.utils.conll import CoNLL
  from stanza.models.common.doc import *
  from stanza.models.tokenization.data import SortedDataset
label_desc: Use image node_id 5 for calling a global function with example usage: process_sentence(sentence, mwt_dict) and returns: sent