def check_vocab_file(file, special_tokens):
    """Check a vocab file, adding special tokens to it.

    Args:
        file: A constant string, path of the vocab file
        special_tokens: A list of special tokens

    Returns:
        The size of the processed vocab.
    """
    vocabs = set()
    with open(file, mode="rt", encoding="utf8", buffering=8192) as f:
        for line in f:
            line = line.strip("\n").strip()
            if not line:
                continue
            if line in special_tokens:
                continue
            vocabs.add(line)
    vocabs = sorted(vocabs)
    for t in reversed(special_tokens):
        vocabs.insert(0, t)
    with open(file, mode="wt", encoding="utf8", buffering=8192) as f:
        for v in vocabs:
            f.write(v + "\n")
    return len(vocabs)