On the Complexity of Learning Sparse Functions with Statistical and Gradient Queries