from typing import Sequence
from typing import Dict
import collections


def make_vocab_dict(tokens: Sequence[str]) -> Dict[str, Sequence[int]]:
  """Creates a dictionary mapping words in the input sentence to their indices.

  Args:
    tokens: The tokens of the input sentence.

  Returns:
    Ordered vocab dictionary mapping words in the input sentence
    to lists of the indices where they occur.
  """
  vocab_dict = collections.OrderedDict()
  for i, token in enumerate(tokens):
    if token not in vocab_dict:
      vocab_dict[token] = []
    vocab_dict[token].append(i)
  return vocab_dict