code: def _init_train(opt):
      """Common initilization stuff for all training process.
      We need to build or rebuild the vocab in 3 cases:
      - training from scratch (train_from is false)
      - resume training but transforms have changed
      - resume training but vocab file has been modified
      """
      ArgumentParser.validate_prepare_opts(opt)
      transforms_cls = get_transforms_cls(opt._all_transform)
      if opt.train_from:
          # Load checkpoint if we resume from a previous training.
          checkpoint = load_checkpoint(ckpt_path=opt.train_from)
          vocabs = dict_to_vocabs(checkpoint["vocab"])
          if (
              hasattr(checkpoint["opt"], "_all_transform")
              and len(
                  opt._all_transform.symmetric_difference(
                      checkpoint["opt"]._all_transform
                  )
              )
              != 0
          ):
              _msg = (
                  "configured transforms is different from checkpoint:"
              )
              new_transf = opt._all_transform.difference(
                  checkpoint["opt"]._all_transform
              )
              old_transf = checkpoint["opt"]._all_transform.difference(
                  opt._all_transform
              )
              if len(new_transf) != 0:
                  _msg += f" +{new_transf}"
              if len(old_transf) != 0:
                  _msg += f" -{old_transf}."
              logger.warning(_msg)
              vocabs = prepare_transforms_vocabs(opt, transforms_cls)
          if opt.update_vocab:
              logger.info(
                  "Updating checkpoint vocabulary with new vocabulary"
              )
              vocabs = prepare_transforms_vocabs(opt, transforms_cls)
      else:
          checkpoint = None
          vocabs = prepare_transforms_vocabs(opt, transforms_cls)
  
      return checkpoint, vocabs, transforms_cls
  
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 2 for calling a global function with example usage: _init_train(opt) and returns: checkpoint,  vocabs,  transforms_cls