code: public static Slice serialize(Model model)
      {
          requireNonNull(model, "model is null");
          Integer id = MODEL_SERIALIZATION_IDS.get(model.getClass());
          requireNonNull(id, "id is null");
          int size = HYPERPARAMETERS_OFFSET;
  
          // hyperparameters aren't implemented yet
          byte[] hyperparameters = new byte[0];
          size += hyperparameters.length;
  
          int dataLengthOffset = size;
          size += SIZE_OF_LONG;
          int dataOffset = size;
          byte[] data = model.getSerializedData();
          size += data.length;
  
          Slice slice = Slices.allocate(size);
          slice.setInt(VERSION_OFFSET, CURRENT_FORMAT_VERSION);
          slice.setInt(ALGORITHM_OFFSET, id);
          slice.setInt(HYPERPARAMETER_LENGTH_OFFSET, hyperparameters.length);
          slice.setBytes(HYPERPARAMETERS_OFFSET, hyperparameters);
          slice.setLong(dataLengthOffset, data.length);
          slice.setBytes(dataOffset, data);
  
          byte[] modelHash = Hashing.sha256().hashBytes(slice.getBytes(ALGORITHM_OFFSET, slice.length() - ALGORITHM_OFFSET)).asBytes();
          checkState(modelHash.length == 32, "sha256 hash code expected to be 32 bytes");
          slice.setBytes(HASH_OFFSET, modelHash);
  
          return slice;
      }
docs: Serializes the model using the following format
  int: format version
  byte[32]: SHA256 hash of all following data
  int: id of algorithm
  int: length of hyperparameters section
  byte[]: hyperparameters (currently not used)
  long: length of data section
  byte[]: model data
  <p>
  note: all multibyte values are in little endian