class_docstr: Generic processors for the sequence samples.
class_docstr_tok: ["Generic","processors","for","the","sequence","samples","."]
code: def build_vocab_generator(
      self, generators: List[CorpusGenerator]
  ) -> None:
      if not self.vocab2idx:
          vocab2idx = self._initial_vocab_dic
  
          token2count: Dict[str, int] = {}
  
          for gen in generators:
              for sentence, label in tqdm.tqdm(
                  gen, desc="Preparing text vocab dict"
              ):
                  if self.build_vocab_from_labels:
                      target = label
                  else:
                      target = sentence
                  for token in target:
                      count = token2count.get(token, 0)
                      token2count[token] = count + 1
  
          sorted_token2count = sorted(
              token2count.items(),
              key=operator.itemgetter(1),
              reverse=True,
          )
          token2count = collections.OrderedDict(sorted_token2count)
  
          for token, token_count in token2count.items():
              if (
                  token not in vocab2idx
                  and token_count >= self.min_count
              ):
                  vocab2idx[token] = len(vocab2idx)
          self.vocab2idx = vocab2idx
          self.idx2vocab = dict(
              [(v, k) for k, v in self.vocab2idx.items()]
          )
  
          top_k_vocab = [
              k for (k, v) in list(self.vocab2idx.items())[:10]
          ]
          logger.debug(
              f"--- Build vocab dict finished, Total: {len(self.vocab2idx)} ---"
          )
          logger.debug(f"Top-10: {top_k_vocab}")
  
file_path: Kashgari/kashgari/processors/sequence_processor.py
imports: import collections
  import operator
  from typing import Dict, List, Any, Optional, Union
  import numpy
  import tqdm
  from tensorflow.keras.preprocessing.sequence import pad_sequences
  from kashgari.generators import CorpusGenerator
  from kashgari.logger import logger
  from kashgari.processors.abc_processor import ABCProcessor
  from kashgari.types import TextSamplesVar
label_desc: Use image node_id 3 for calling the SequenceProcessor obj's underlying member method code with example usage: obj.build_vocab_generator(generators) without return types