training function return error within multi-threading