<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def save_spec(spec, filename):
 """ Save a protobuf model specification to file. Parameters spec: Model_pb Protobuf representation of the model filename: str File path where the spec gets saved. Examples -------- .. sourcecode:: python See Also -------- load_spec """

    name, ext = _os.path.splitext(filename)
    if not ext:
        filename = "%s.mlmodel" % filename
    else:
        if ext != '.mlmodel':
            raise Exception("Extension must be .mlmodel (not %s)" % ext)

    with open(filename, 'wb') as f:
        s = spec.SerializeToString()
        f.write(s)