class_docstr: Dictionary encapsulates the mapping between normalized words and their integer ids.
  
  Notable instance attributes:
  
  Attributes
  ----------
  token2id : dict of (str, int)
      token -> token_id. I.e. the reverse mapping to `self[token_id]`.
  cfs : dict of (int, int)
      Collection frequencies: token_id -> how many instances of this token are contained in the documents.
  dfs : dict of (int, int)
      Document frequencies: token_id -> how many documents contain this token.
  num_docs : int
      Number of documents processed.
  num_pos : int
      Total number of corpus positions (number of processed words).
  num_nnz : int
      Total number of non-zeroes in the BOW matrix (sum of the number of unique
      words per document over the entire corpus).
class_docstr_tok: ["Dictionary","encapsulates","the","mapping","between","normalized","words","and","their","integer","ids",".","Notable","instance","attributes",":","Attributes","--","--","--","--","--","token2id",":","dict","of","(","str",",","int",")","token","-",">","token_id",".","I.e",".","the","reverse","mapping","to","`","self","[","token_id","]","`",".","cfs",":","dict","of","(","int",",","int",")","Collection","frequencies",":","token_id","-",">","how","many","instances","of","this","token","are","contained","in","the","documents",".","dfs",":","dict","of","(","int",",","int",")","Document","frequencies",":","token_id","-",">","how","many","documents","contain","this","token",".","num_docs",":","int","Number","of","documents","processed",".","num_pos",":","int","Total","number","of","corpus","positions","(","number","of","processed","words",")",".","num_nnz",":","int","Total","number","of","non-zeroes","in","the","BOW","matrix","(","sum","of","the","number","of","unique","words","per","document","over","the","entire","corpus",")","."]
docstr: Filter out the 'remove_n' most frequent tokens that appear in the documents.
  
  Parameters
  ----------
  remove_n : int
      Number of the most frequent tokens that will be removed.
  
  Examples
  --------
  .. sourcecode:: pycon
  
      >>> from gensim.corpora import Dictionary
      >>>
      >>> corpus = [["máma", "mele", "maso"], ["ema", "má", "máma"]]
      >>> dct = Dictionary(corpus)
      >>> len(dct)
      5
      >>> dct.filter_n_most_frequent(2)
      >>> len(dct)
      3
docstr_tok: ["Filter","out","the","'remove_n","'","most","frequent","tokens","that","appear","in","the","documents",".","Parameters","--","--","--","--","--","remove_n",":","int","Number","of","the","most","frequent","tokens","that","will","be","removed",".","Examples","--","--","--","--","..","sourcecode",":",":","pycon",">",">",">","from","gensim.corpora","import","Dictionary",">",">",">",">",">",">","corpus","=","[","[","``","m\u00e1ma","''",",","``","mele","''",",","``","maso","''","]",",","[","``","ema","''",",","``","m\u00e1","''",",","``","m\u00e1ma","''","]","]",">",">",">","dct","=","Dictionary","(","corpus",")",">",">",">","len","(","dct",")","5",">",">",">","dct.filter_n_most_frequent","(","2",")",">",">",">","len","(","dct",")","3"]
code: def filter_n_most_frequent(self, remove_n):
      """Filter out the 'remove_n' most frequent tokens that appear in the documents.
  
      Parameters
      ----------
      remove_n : int
          Number of the most frequent tokens that will be removed.
  
      Examples
      --------
      .. sourcecode:: pycon
  
          >>> from gensim.corpora import Dictionary
          >>>
          >>> corpus = [["máma", "mele", "maso"], ["ema", "má", "máma"]]
          >>> dct = Dictionary(corpus)
          >>> len(dct)
          5
          >>> dct.filter_n_most_frequent(2)
          >>> len(dct)
          3
  
      """
      # determine which tokens to keep
      most_frequent_ids = (v for v in self.token2id.values())
      most_frequent_ids = sorted(
          most_frequent_ids, key=self.dfs.get, reverse=True
      )
      most_frequent_ids = most_frequent_ids[:remove_n]
      # do the actual filtering, then rebuild dictionary to remove gaps in ids
      most_frequent_words = [
          (self[idx], self.dfs.get(idx, 0)) for idx in most_frequent_ids
      ]
      logger.info(
          "discarding %i tokens: %s...",
          len(most_frequent_ids),
          most_frequent_words[:10],
      )
  
      self.filter_tokens(bad_ids=most_frequent_ids)
      logger.info("resulting dictionary: %s", self)
  
imports: from collections import defaultdict
  from collections.abc import Mapping
  import logging
  import itertools
  from typing import Optional, List, Tuple
  from gensim import utils
label_desc: Use image node_id 14 for calling the Dictionary obj's underlying member method code with example usage: obj.filter_n_most_frequent(remove_n) without return types