def finalize(self, vocab=None):
        """
        Fixes the vocabulary as static, prevents keeping additional vocab from
        being added
        """
        self._vocab_final = True
        if vocab is None:
            self._vocab_size = min(len(self._training_counts),
                                   self._vocab_size)
            vocab = sorted(self._training_counts,
                           key=lambda x: self._training_counts[x],
                           reverse=True)[:self._vocab_size]
            self._vocab = dict((x, y + 1) for y, x in enumerate(vocab))
            assert not self._vocab in kUNK, "Vocab already has %s" % kUNK
            self._vocab[kUNK] = 0
        else:
            self._vocab = vocab

        # -------------------------------------------------
        # Add one for the unknown tokens
        del self._training_counts
        return self._vocab
dataset/ETHPy150Open Pinafore/qb/clm/lm_wrapper.py/LanguageModelWriter.finalize/swapped operands of `in`