code: def save_spec(spec, filename):
      
      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)
docs: 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
  
          >>> coremltools.utils.save_spec(spec, 'HousePricer.mlmodel')
  
      See Also
      --------
      load_spec