code: def build_embeddings(opt, vocabs, for_encoder=True):
      """
      Args:
          opt: the option in current environment.
          vocab.
          for_encoder(bool): build Embeddings for encoder or decoder?
      """
      feat_pad_indices = []
      num_feat_embeddings = []
      if for_encoder:
          emb_dim = opt.src_word_vec_size
          word_padding_idx = vocabs["src"][DefaultTokens.PAD]
          num_word_embeddings = len(vocabs["src"])
          if "src_feats" in vocabs:
              feat_pad_indices = [
                  fv[DefaultTokens.PAD] for fv in vocabs["src_feats"]
              ]
              num_feat_embeddings = [
                  len(fv) for fv in vocabs["src_feats"]
              ]
          freeze_word_vecs = opt.freeze_word_vecs_enc
      else:
          emb_dim = opt.tgt_word_vec_size
          word_padding_idx = vocabs["tgt"][DefaultTokens.PAD]
          num_word_embeddings = len(vocabs["tgt"])
          freeze_word_vecs = opt.freeze_word_vecs_dec
  
      emb = Embeddings(
          word_vec_size=emb_dim,
          position_encoding=opt.position_encoding,
          position_encoding_type=opt.position_encoding_type,
          feat_merge=opt.feat_merge,
          feat_vec_exponent=opt.feat_vec_exponent,
          feat_vec_size=opt.feat_vec_size,
          dropout=opt.dropout[0]
          if type(opt.dropout) is list
          else opt.dropout,
          word_padding_idx=word_padding_idx,
          feat_padding_idx=feat_pad_indices,
          word_vocab_size=num_word_embeddings,
          feat_vocab_sizes=num_feat_embeddings,
          sparse=opt.optim == "sparseadam",
          freeze_word_vecs=freeze_word_vecs,
      )
      return emb
  
imports: import torch
  import torch.nn
  from torch.nn.utils import skip_init
  from torch.nn.init import xavier_uniform_, zeros_, uniform_
  from onmt.models.model import NMTModel, LanguageModel
  from onmt.encoders import str2enc
  from onmt.decoders import str2dec
  from onmt.inputters.inputter import dict_to_vocabs
  from onmt.modules import Embeddings, CopyGenerator
  from onmt.utils.misc import use_gpu
  from onmt.utils.logging import logger
  from onmt.utils.parse import ArgumentParser
  from onmt.models.model_saver import load_checkpoint
  from onmt.constants import DefaultTokens, ModelTask
  from onmt.modules.lora import replace_lora_linear, replace_lora_embedding, mark_only_lora_as_trainable
label_desc: Use image node_id 1 for calling a global function with example usage: build_embeddings(opt, vocabs, for_encoder) and returns: emb