defined a predict_all function that calls predict on all elements in a list.