code: def _finalize_outputs(cls, mapreduce_spec, mapreduce_state):
      
      # Only finalize the output writers if the job is successful.
      if (mapreduce_spec.mapper.output_writer_class() and
          mapreduce_state.result_status == model.MapreduceState.RESULT_SUCCESS):
        mapreduce_spec.mapper.output_writer_class().finalize_job(mapreduce_state)
docs: Finalize outputs.
  
      Args:
        mapreduce_spec: an instance of MapreduceSpec.
        mapreduce_state: an instance of MapreduceState.