code: def match_tokens_with_text(sentences, orig_text):
      """
      Turns pretokenized text and the original text into a Doc object
  
      sentences: list of list of string
      orig_text: string, where the text must be exactly the sentences
        concatenated with 0 or more whitespace characters
  
      if orig_text deviates in any way, a ValueError will be thrown
      """
      text = "".join(["".join(x) for x in sentences])
      all_raw = list(text)
      all_preds = [0] * len(all_raw)
      offset = 0
      for sentence in sentences:
          for word in sentence:
              offset += len(word)
              all_preds[offset - 1] = 1
          all_preds[offset - 1] = 2
      _, _, doc = decode_predictions(
          None,
          None,
          orig_text,
          [all_raw],
          [all_preds],
          False,
          False,
          False,
      )
      doc = Document(doc, orig_text)
  
      # check that all the orig_text was used up by the tokens
      offset = doc.sentences[-1].tokens[-1].end_char
      remainder = orig_text[offset:].strip()
      if len(remainder) > 0:
          raise ValueError(
              "Finished processing tokens, but there is still text left!"
          )
  
      return doc
  
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 13 for calling a global function with example usage: match_tokens_with_text(sentences, orig_text) and returns: doc