def save_vocab(self, vocab):
    """Save the vocabulary to a file.

    Args:
      vocab: dict
    """
    voc_file = open(os.path.join(self._data_dir, self.vocab_file), 'w')

    # Put the reserved tokens in.
    voc_file.write('<pad>\n')
    voc_file.write('<EOS>\n')
    for word, _ in vocab.most_common(self.targeted_vocab_size - 3):
      voc_file.write(word + '\n')
    voc_file.write('<unk>')

    voc_file.close()
Save the vocabulary to a file.

    Args:
      vocab: dict
    
tensor2tensor/data_generators/dialog_abstract.py