docstr: Limit the vocabulary size.
docstr_tok: ["Limit","the","vocabulary","size","."]
code: def max_vocab(self, max_vocab):
      """
      Limit the vocabulary size.
      """
      assert max_vocab >= 1
      init_size = len(self)
      self.id2word = {
          k: v for k, v in self.id2word.items() if k < max_vocab
      }
      self.word2id = {v: k for k, v in self.id2word.items()}
      self.counts = {
          k: v for k, v in self.counts.items() if k in self.word2id
      }
      self.check_valid()
      logger.info(
          "Maximum vocabulary size: %i. Dictionary size: %i -> %i (removed %i words)."
          % (max_vocab, init_size, len(self), init_size - len(self))
      )
  
file_path: pytext/pytext/data/xlm_dictionary.py
imports: import os
  from logging import getLogger
  import numpy
  import torch
  from pytext.utils.file_io import PathManager
label_desc: Use image node_id 8 for calling the Dictionary obj's underlying member method code with example usage: obj.max_vocab(max_vocab) without return types