Optimal importance sampling for federated learning