code: def test_batch_bow(self):
      (a, b, c, d, e, f) = self.token_ids
      shift = len(SPECIAL_TOKENS)
  
      batch_bows = self.modality.batch_bow([2, 1])
      self.assertEqual((2, self.modality.max_vocab), batch_bows.shape)
      expected_bows = np.zeros_like(batch_bows)
      expected_bows[0, b - shift] = 1
      expected_bows[0, c - shift] = 2
      expected_bows[0, e - shift] = 1
      expected_bows[0, f - shift] = 1
      expected_bows[1, b - shift] = 1
      expected_bows[1, c - shift] = 1
      expected_bows[1, d - shift] = 2
      npt.assert_array_equal(batch_bows, expected_bows)
  
      batch_bows = self.modality.batch_bow(
          [0, 2], binary=True, keep_sparse=True
      )
      self.assertEqual((2, 6), batch_bows.shape)
      expected_bows = np.zeros_like(batch_bows.A)
      expected_bows[0, np.asarray([a, b, c]) - shift] = 1
      expected_bows[1, np.asarray([b, c, e, f]) - shift] = 1
      npt.assert_array_equal(batch_bows.A, expected_bows)
  
      self.modality.count_matrix = None
      try:
          self.modality.batch_bow([0])
      except ValueError:
          assert True
  
imports: import unittest
  from collections import defaultdict
  import numpy
  import numpy.testing
  from cornac.data import TextModality, ReviewModality
  from cornac.data.text import SPECIAL_TOKENS, DEFAULT_PRE_RULES, BaseTokenizer, Vocabulary, CountVectorizer, TfidfVectorizer
label_desc: Use image node_id 7 for calling the TestTextModality obj's underlying member method code with example usage: obj.test_batch_bow() without return types