A General Method for Robust Learning from Batches