SPARK-3179. Add task OutputMetrics.

Why did you change this?  I think it makes the code slightly harder to read / understand, because it's not obvious without reading all of the code around here why inputMetrics will always be non-None