To apply the preprocessing function over the entire dataset, use 🤗 Datasets [~datasets.Dataset.map] function. You can speed up map by increasing the number of processes with the num_proc parameter. Remove the columns you don't need with the [~datasets.Dataset.remove_columns] method:

encoded_minds = minds.map(prepare_dataset, remove_columns=minds.column_names["train"], num_proc=4)