MAGIC: Near-Optimal Data Attribution for Deep Learning