code: def build_sub_vocab(
      corpora, transforms, opts, n_sample, stride, offset
  ):
      """Build vocab on (strided) subpart of the data."""
      sub_counter_src = Counter()
      sub_counter_tgt = Counter()
      sub_counter_src_feats = [
          Counter() for _ in range(opts.n_src_feats)
      ]
      datasets_iterables = build_corpora_iters(
          corpora,
          transforms,
          opts.data,
          skip_empty_level=opts.skip_empty_level,
          stride=stride,
          offset=offset,
      )
      for c_name, c_iter in datasets_iterables.items():
          for i, item in enumerate(c_iter):
              maybe_example = process(CorpusTask.TRAIN, [item])
              if maybe_example is not None:
                  maybe_example = maybe_example[0]
              else:
                  if opts.dump_samples:
                      build_sub_vocab.queues[c_name][offset].put(
                          "blank"
                      )
                  continue
              src_line, tgt_line = (
                  maybe_example["src"]["src"],
                  maybe_example["tgt"]["tgt"],
              )
              sub_counter_src.update(src_line.split(" "))
              sub_counter_tgt.update(tgt_line.split(" "))
  
              if "feats" in maybe_example["src"]:
                  src_feats_lines = maybe_example["src"]["feats"]
                  for k in range(opts.n_src_feats):
                      sub_counter_src_feats[k].update(
                          src_feats_lines[k].split(" ")
                      )
              else:
                  src_feats_lines = []
  
              if opts.dump_samples:
                  src_pretty_line = append_features_to_text(
                      src_line, src_feats_lines
                  )
                  build_sub_vocab.queues[c_name][offset].put(
                      (i, src_pretty_line, tgt_line)
                  )
              if (
                  n_sample > 0
                  and ((i + 1) * stride + offset) >= n_sample
              ):
                  if opts.dump_samples:
                      build_sub_vocab.queues[c_name][offset].put(
                          "break"
                      )
                  break
          if opts.dump_samples:
              build_sub_vocab.queues[c_name][offset].put("break")
      return sub_counter_src, sub_counter_tgt, sub_counter_src_feats
  
imports: import os
  import copy
  import multiprocessing
  import pyonmttok
  from functools import partial
  from onmt.utils.logging import init_logger, logger
  from onmt.utils.misc import set_random_seed, check_path
  from onmt.utils.parse import ArgumentParser
  from onmt.opts import data_prepare_opts
  from onmt.inputters.text_corpus import build_corpora_iters, get_corpora
  from onmt.inputters.text_utils import process, append_features_to_text
  from onmt.transforms import make_transforms, get_transforms_cls
  from onmt.constants import CorpusName, CorpusTask
  from collections import Counter
label_desc: Use image node_id 2 for calling a global function with example usage: build_sub_vocab(corpora, transforms, opts, n_sample, stride, offset) and returns: sub_counter_src,  sub_counter_tgt,  sub_counter_src_feats