code: def build_vocab_from_iterator(iterator, num_lines=None):
      """
      Build a Vocab from an iterator.
  
      Args:
          iterator: Iterator used to build Vocab. Must yield list or iterator of tokens.
          num_lines: The expected number of elements returned by the iterator.
              (Default: None)
              Optionally, if known, the expected number of elements can be passed to
              this factory function for improved progress reporting.
      """
  
      counter = Counter()
      with tqdm(unit_scale=0, unit="lines", total=num_lines) as t:
          for tokens in iterator:
              counter.update(tokens)
              t.update(1)
      word_vocab = Vocab(counter)
      return word_vocab
  
file_path: pytext/pytext/legacy/vocab.py
imports: import logging
  from collections import Counter, defaultdict
  import torch
  from torchtext.vocab import pretrained_aliases, Vectors
  from tqdm import tqdm
label_desc: Use image node_id 1 for calling a global function with example usage: build_vocab_from_iterator(iterator, num_lines) and returns: word_vocab