code: def rebuild_offset_from_tokens(
      sentence: str, tokens: List[str]
  ) -> List[Tuple[int, int]]:
      """Recover the offset of the tokens in the original sentence.
  
      If you are using a subword tokenizer, make sure to remove the prefix/postfix of the tokens
      before using this function. Also, this does not work for n-gram-based (n>1) subword
      tokenization, i.e.
      it works for "gluonnlp" --> ["gluon", "nlp"]
      but not for "gluonnlp" --> ["gl", "lu", "uo", "on", "nl", "lp"]
  
      Parameters
      ----------
      sentence
          The input sentence
      tokens
          A list of strings that represent the tokenization result
  
      Returns
      -------
      offsets
          A list of start+end pairs: [(start0, end0), (start1, end1), ...].
          Each pair represents the start and end positions of the token in the original
          sentence.
      """
      running_offset = 0
      ret = []
      for token in tokens:
          token_offset = sentence.index(token, running_offset)
          token_len = len(token)
          running_offset = token_offset + token_len
          ret.append((token_offset, running_offset))
      return ret
  
imports: import abc
  import itertools
  from ..vocab import Vocab
  from ...utils.registry import Registry
  from typing import List, Tuple, Union, NewType, Optional
label_desc: Use image node_id 3 for calling a global function with example usage: rebuild_offset_from_tokens(sentence, tokens) and returns: ret