code: def build_encoder(opt, embeddings):
      """
      Various encoder dispatcher function.
      Args:
          opt: the option in current environment.
          embeddings (Embeddings): vocab embeddings for this encoder.
      """
      enc_type = (
          opt.encoder_type
          if opt.model_type == "text"
          else opt.model_type
      )
      return str2enc[enc_type].from_opt(opt, embeddings)
  
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 2 for calling a global function with example usage: build_encoder(opt, embeddings) and returns: str2enc