from typing import List
import random


def mask_seq(seq: List, p: float, mask='<mask>'):
    """
    Randomly mask tokens in sequence

    Args:
        seq: original sequence
        p: mask probability
        mask: mask token

    Returns:
        - sequence with token mask
    """
    seq = [mask if random.random() < p else s for s in seq]
    return seq