Optimal score estimation via empirical Bayes smoothing