code: def test_batch_generator(self):
      x, y = ChineseDailyNerCorpus.load_data("valid")
  
      text_processor = SequenceProcessor()
      label_processor = SequenceProcessor(
          build_vocab_from_labels=True, min_count=1
      )
  
      corpus_gen = CorpusGenerator(x, y)
  
      text_processor.build_vocab_generator([corpus_gen])
      label_processor.build_vocab_generator([corpus_gen])
  
      batch_dataset = BatchDataSet(
          corpus_gen,
          text_processor=text_processor,
          label_processor=label_processor,
          segment=False,
          seq_length=None,
          max_position=100,
          batch_size=12,
      )
  
      duplicate_len = len(batch_dataset)
      assert (
          len(list(batch_dataset.take(duplicate_len))) == duplicate_len
      )
      assert len(list(batch_dataset.take(1))) == 1
  
file_path: Kashgari/tests/test_generator.py
imports: import unittest
  from kashgari.corpus import ChineseDailyNerCorpus
  from kashgari.generators import CorpusGenerator, BatchDataSet
  from kashgari.processors import SequenceProcessor
  from tests.test_macros import TestMacros
label_desc: Use image node_id 2 for calling the TestGenerator obj's underlying member method code with example usage: obj.test_batch_generator() without return types