Generalizing Stochastic Smoothing for Differentiation and Gradient Estimation