def remove_unknown_chars(tokens, tokenizer):
    """Replaces unknown characters with a special [UNK] token."""
    for i, t in enumerate(tokens):
        try:
            tokenizer.vocab[t]
        except KeyError:
            tokens[i] = "[UNK]"
    return tokens