def save(self):
    """Persist the encoder and the model to disk.
    """
    if self._model is None or self._encoder is None:
      raise ValueError('Model and encoder cannot be None')
    else:
      self._encoder.save_to_file(
          # This is a prefix, which converts to: mydir/text_encoder.tokens
          os.path.join(self._model_config.model_checkpoint, 'text_encoder'))
      self._model.save_weights(
          os.path.join(self._model_config.model_checkpoint, 'best_model.tf'))
Persist the encoder and the model to disk.
    
language/serene/training.py