from pathlib import Path def write_prediction(prediction, output_path): import numpy as np output_path = Path(output_path) output_path.parent.mkdir(parents=True, exist_ok=True) np.savez( output_path, **{name: np.asarray(value) for name, value in prediction.items()}, ) return output_path