from typing import Sequence
from typing import Dict


def get_masks(counterfactuals: Sequence[Sequence[str]],
              vocab_to_indices: Dict[str, Sequence[int]]):
  """Returns masks indicating if counterfactual tokens are in original sentence.

  Args:
    counterfactuals: The tokens of the input's counterfactuals.
    vocab_to_indices: A dictionary mapping unique tokens in the input sentence
      to the indices of its occurrence in the original sentence.

  Returns:
    A list of masks, which are lists of booleans corresponding to tokens.
  """
  masks = []
  for counterfactual in counterfactuals:
    counterfactual_tokens = set(counterfactual)
    masks.append([
        (token in counterfactual_tokens) for token in vocab_to_indices.keys()
    ])
  return masks