def build_mask(sequence, pad_token_id):
    """Builds the mask. The attention mechanism will only attend to positions
    with value 1."""
    mask = torch.ones_like(sequence)
    idx_pad_tokens = sequence == pad_token_id
    mask[idx_pad_tokens] = 0
    return mask
Builds the mask. The attention mechanism will only attend to positions
    with value 1.
dpkd/transformers/examples/research_projects/bertabs/utils_summarization.py