You should just use the tokenizer __call__: tokenizer(example["text"]).
__call__
tokenizer(example["text"])