def save_model(model, file_path):
    """
    Saves an ONNX model to a ProtoBuf object.
    :param model: ONNX model
    :param file_path: ONNX file (full file name)

    Example:

    ::

        from onnxmltools.utils import save_model
        save_model(onnx_model, 'c:/test_model.onnx')
    """
    if model is None or not isinstance(model, onnx_proto.ModelProto):
        raise ValueError("Model is not a valid ONNX model.")
    directory = os.path.dirname(os.path.abspath(file_path))
    if not path.exists(directory):
        raise FileNotFoundError("Directory does not exist {0}".format(directory))
    with open(file_path, 'wb') as f:
        f.write(model.SerializeToString())
Saves an ONNX model to a ProtoBuf object.
    :param model: ONNX model
    :param file_path: ONNX file (full file name)

    Example:

    ::

        from onnxmltools.utils import save_model
        save_model(onnx_model, 'c:/test_model.onnx')