code: def update_pred_regex(raw, pred):
      """
      Update the results of a tokenization batch by checking the raw text against a couple regular expressions
  
      Currently, emails and urls are handled
      TODO: this might work better as a constraint on the inference
  
      for efficiency pred is modified in place
      """
      spans = find_spans(raw)
  
      for span_begin, span_end in spans:
          text = "".join(raw[span_begin:span_end])
          for match in MASK_RE.finditer(text):
              match_begin, match_end = match.span()
              # first, update all characters touched by the regex to not split
              # with the exception of the last character...
              for char in range(
                  match_begin + span_begin, match_end + span_begin - 1
              ):
                  pred[char] = 0
              # if the last character is not currently a split, make it a word split
              if pred[match_end + span_begin - 1] == 0:
                  pred[match_end + span_begin - 1] = 1
  
      return pred
  
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 7 for calling a global function with example usage: update_pred_regex(raw, pred) and returns: pred