def build_mask(sequence, pad_token_id):
    """ Builds the mask. The attention mechanism will only attend to positions
    with value 1.

    Args:
        sequence (list): sequences for which the mask is built for.
        pad_token_id (long): padding token id for which the mask is 0.

    Returns:
        mask (list): sequences of 1s and 0s.

    """
    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.

    Args:
        sequence (list): sequences for which the mask is built for.
        pad_token_id (long): padding token id for which the mask is 0.

    Returns:
        mask (list): sequences of 1s and 0s.

    
utils_nlp/models/transformers/abstractive_summarization_bertsum.py