code: def prepare_transforms_vocabs(opt, transforms_cls):
      """Prepare or dump transforms before training."""
      # if transform + options set in 'valid' we need to copy in main
      # transform / options for scoring considered as inference
      validset_transforms = opt.data.get("valid", {}).get(
          "transforms", None
      )
      if validset_transforms:
          opt.transforms = validset_transforms
          if opt.data.get("valid", {}).get("tgt_prefix", None):
              opt.tgt_prefix = opt.data.get("valid", {}).get(
                  "tgt_prefix", None
              )
              opt.tgt_file_prefix = True
          if opt.data.get("valid", {}).get("src_prefix", None):
              opt.src_prefix = opt.data.get("valid", {}).get(
                  "src_prefix", None
              )
          if opt.data.get("valid", {}).get("tgt_suffix", None):
              opt.tgt_suffix = opt.data.get("valid", {}).get(
                  "tgt_suffix", None
              )
          if opt.data.get("valid", {}).get("src_suffix", None):
              opt.src_suffix = opt.data.get("valid", {}).get(
                  "src_suffix", None
              )
      specials = get_specials(opt, transforms_cls)
  
      vocabs = build_vocab(opt, specials)
  
      # maybe prepare pretrained embeddings, if any
      prepare_pretrained_embeddings(opt, vocabs)
  
      if opt.dump_transforms or opt.n_sample != 0:
          transforms = make_transforms(opt, transforms_cls, vocabs)
      if opt.dump_transforms:
          save_transforms(
              transforms, opt.save_data, overwrite=opt.overwrite
          )
      if opt.n_sample != 0:
          logger.warning(
              "`-n_sample` != 0: Training will not be started. "
              f"Stop after saving {opt.n_sample} samples/corpus."
          )
          save_transformed_sample(
              opt, transforms, n_sample=opt.n_sample
          )
          logger.info(
              "Sample saved, please check it before restart training."
          )
          sys.exit()
      logger.info(
          "The first 10 tokens of the vocabs are:"
          f"{vocabs_to_dict(vocabs)['src'][0:10]}"
      )
      logger.info(
          f"The decoder start token is: {opt.decoder_start_token}"
      )
      return vocabs
  
imports: import torch
  import sys
  from onmt.utils.logging import init_logger, logger
  from onmt.utils.parse import ArgumentParser
  from onmt.constants import CorpusTask
  from onmt.transforms import make_transforms, save_transforms, get_specials, get_transforms_cls
  from onmt.inputters import build_vocab
  from onmt.inputters.inputter import dict_to_vocabs, vocabs_to_dict
  from onmt.inputters.dynamic_iterator import build_dynamic_dataset_iter
  from onmt.inputters.text_corpus import save_transformed_sample
  from onmt.model_builder import build_model
  from onmt.models.model_saver import load_checkpoint
  from onmt.utils.optimizers import Optimizer
  from onmt.utils.misc import set_random_seed
  from onmt.trainer import build_trainer
  from onmt.models import build_model_saver
  from onmt.modules.embeddings import prepare_pretrained_embeddings
label_desc: Use image node_id 1 for calling a global function with example usage: prepare_transforms_vocabs(opt, transforms_cls) and returns: vocabs