code: def test_trim_vocab(self):
      d = {"word1": 5, "word2": 1, "word3": 2}
      expected_dict = {"word1": 5, "word3": 2}
      utils.trim_vocab_by_freq(d, topk=2)
      self.assertEqual(d, expected_dict)
  
      d = {"word1": 5, "word2": 2, "word3": 2, "word4": 1}
      expected_dict = {"word1": 5, "word2": 2, "word3": 2}
      utils.trim_vocab_by_freq(d, topk=2)
      self.assertEqual(d, expected_dict)
  
imports: import logging
  import unittest
  import numpy
  from gensim import utils
  from gensim.test.utils import datapath, get_tmpfile
label_desc: Use image node_id 1 for calling the TestTrimVocabByFreq obj's underlying member method code with example usage: obj.test_trim_vocab() without return types