CompressionMode comp = CompressionMode.autodetect(output);
logger.info("writing model to {}", output);
Closer closer = Closer.create();
try {
OutputStream stream = closer.register(new FileOutputStream(output));
stream = closer.register(comp.wrapOutput(stream));
engine.write(stream);
} catch (Throwable th) {
throw closer.rethrow(th);
} finally {
closer.close();