code: def _spacy_token_predictions(raw_text, tokens, probas, positions):
      """
      Go from GPT subtoken level predictions, to spacy token predictions
      """
      to_combine = []
      nlp = get_spacy()
  
      spacy_token_starts, spacy_token_ends = zip(
          *[
              (token.idx, token.idx + len(token.text))
              for token in nlp(raw_text)
          ]
      )
      spacy_token_idx = 0
      spacy_results = []
  
      for token, prob, (start, end) in zip(tokens, probas, positions):
          to_combine.append(
              {
                  "start": start,
                  "end": end,
                  "token": token,
                  "probabilities": prob,
              }
          )
          try:
              end_match = spacy_token_ends.index(end, spacy_token_idx)
              start = spacy_token_starts[end_match]
              spacy_token_idx = end_match
          except ValueError:
              continue
  
          spacy_results.append(
              _combine_and_format(
                  to_combine, start=start, end=end, raw_text=raw_text
              )
          )
          to_combine = []
  
      return spacy_results
  
imports: import copy
  import os
  from collections import Counter, defaultdict
  import math
  from typing import Dict, List, Tuple, Union
  import tensorflow
  import numpy
  from finetune.base import BaseModel
  from finetune.encoding.target_encoders import SequenceLabelingEncoder, SequenceMultiLabelingEncoder
  from finetune.nn.target_blocks import sequence_labeler
  from finetune.nn.crf import sequence_decode
  from finetune.encoding.sequence_encoder import finetune_to_indico_sequence
  from finetune.encoding.input_encoder import get_spacy
  from finetune.input_pipeline import BasePipeline
  from finetune.util.metrics import sequences_overlap
  from finetune.encoding.input_encoder import tokenize_context
label_desc: Use image node_id 2 for calling a global function with example usage: _spacy_token_predictions(raw_text, tokens, probas, positions) and returns: spacy_results