code: def testFilterKeepTokens_keepn(self):
      # keep_tokens should also work if the keep_n parameter is used, but only
      # to keep a maximum of n (so if keep_n < len(keep_n) the tokens to keep are
      # still getting removed to reduce the size to keep_n!)
      d = Dictionary(self.texts)
      # Note: there are four tokens with freq 3, all the others have frequence 2
      # in self.texts. In order to make the test result deterministic, we add
      # 2 tokens of frequency one
      d.add_documents([["worda"], ["wordb"]])
      # this should keep the 3 tokens with freq 3 and the one we want to keep
      d.filter_extremes(
          keep_n=5, no_below=0, no_above=1.0, keep_tokens=["worda"]
      )
      expected = {"graph", "trees", "system", "user", "worda"}
      self.assertEqual(set(d.token2id.keys()), expected)
  
imports: from collections.abc import Mapping
  from itertools import chain
  import logging
  import unittest
  import codecs
  import os
  import os.path
  import scipy
  import gensim
  from gensim.corpora import Dictionary
  from gensim.utils import to_utf8
  from gensim.test.utils import get_tmpfile, common_texts
label_desc: Use image node_id 12 for calling the TestDictionary obj's underlying member method code with example usage: obj.testFilterKeepTokens_keepn() without return types