Optimizing Black-box Metrics with Iterative Example Weighting