def find_answer_spans_sentencepiece(tokenized_context: TokenizedText,
                                    answer: str) -> List[Tuple[int, int]]:
  """Finds all answer occurrence SentencePiece token spans (inclusive).

  Args:
    tokenized_context: SentencePiece tokenized context with indices mapping.
    answer: Answer string.

  Returns:
    A list of (begin, end) WordPiece token level indices (inclusive) of all the
    answer occurrences in the context. If the answer is empty or there is no
    answer occurrence in the context, return empty list.
  """
  # The answer occurrence always corresponds to char level occurrence.
  # This is to avoid the following case,
  #     context: "..Italian composer who wrote 39 operas.."
  #     answer:  "opera"
  # Since both "operas" and "opera" are in the vocab, simply searching token
  # level spans will miss such kind of occurrence.
  token_spans = []
  for char_begin, char_end in find_char_spans(tokenized_context.text, answer):
    token_spans.append((tokenized_context.chars_to_tokens[char_begin],
                        tokenized_context.chars_to_tokens[char_end]))
  return token_spans