def convert_to_spans(raw_text, tokens):
  """Convert tokenized version of `raw_text` to character spans into it.

  Args:
    raw_text: The raw string
    tokens: The tokenized version of the string


  Returns:
    [list of (start, end) tuples] mapping each token to corresponding indices
    in the text.
  """
  cur_idx = 0
  spans = []
  for token in tokens:
    tmp = raw_text.find(token, cur_idx)
    l = len(token)
    cur_idx = tmp
    spans.append((cur_idx, cur_idx + l))
    cur_idx += l
  return spans