code: def build_encoder(cls, args, task):
      # text_encoder = cls.build_text_encoder(args, task.source_dictionary )
      text_encoder = cls.build_text_encoder(args, task.src_dict)
      speech_encoder = cls.build_speech_encoder(args)
      if args.load_pretrained_wav2vec_encoder:
          component_pairs = (
              ("feature_extractor", speech_encoder.subsample),
              ("post_extract_proj", speech_encoder.feat_proj),
              ("layer_norm", speech_encoder.feat_layer_norm),
              ("encoder.pos_conv", speech_encoder.embed_positions),
              ("encoder.layers", speech_encoder.layers),
              ("encoder.layer_norm", speech_encoder.layer_norm),
              ("mask_emb", speech_encoder.mask_emb),
          )
          state = cls.load_pretrained_speech_text_components(
              args.load_pretrained_wav2vec_encoder, component_pairs
          )
          cls.check_args(
              args.encoder_normalize_before
              == state["cfg"]["model"]["layer_norm_first"],
              not args.no_strict_check_pretrain_model,
              f"encoder_normalize_before {args.encoder_normalize_before} doesn't match with the pretrained model",
          )
          cls.check_args(
              args.activation_fn
              == state["cfg"]["model"]["activation_fn"],
              not args.no_strict_check_pretrain_model,
              f"activation_fn {args.activation_fn} doesn't match with the pretrained model",
          )
  
      if getattr(args, "stacked_encoder", False):
          if args.encoder_shared_text_layers_from_begin > 0:
              raise ValueError(
                  "We can not stack encoders and share encoders at the same time!"
              )
          speech_encoder = StackedSpeechWavTransformerEncoder(
              speech_encoder,
              text_encoder.layers,
              text_encoder.layer_norm,
          )
      else:
          cls.share_speech_text_encoder(
              speech_encoder,
              text_encoder,
              args.encoder_shared_text_layers_from_begin,
          )
  
      cross_attentive_loss_before_last_layer = (
          0
          if getattr(args, "attentive_cost_regularization", 0.0) > 0.0
          else -1
      )
      encoder = DualInputEncoder(
          args,
          speech_encoder,
          text_encoder,
          task.src_dict,
          cross_attentive_loss_before_last_layer,
      )
      if args.load_pretrained_speech_text_encoder:
          component_pairs = (
              ("encoder.sup_s2s_speech_encoder", encoder.spch_encoder),
              ("encoder.text_encoder", encoder.text_encoder),
          )
          cls.load_pretrained_speech_text_components(
              args.load_pretrained_speech_text_encoder, component_pairs
          )
      if getattr(args, "load_init_encoder", "") != "":
          checkpoint_utils.load_pretrained_component_from_model(
              encoder, args.load_init_encoder
          )
      return encoder
  
imports: import logging
  from collections import OrderedDict, namedtuple
  import torch.nn
  from fairseq import checkpoint_utils, utils
  from fairseq.checkpoint_utils import load_checkpoint_to_cpu
  from fairseq.file_io import PathManager
  from fairseq.models import register_model, register_model_architecture
  from fairseq.models.speech_to_text import SpeechWavTransformerEncoder, StackedSpeechWavTransformerEncoder, TransformerDecoder
  from fairseq.models.transformer import TransformerEncoder
  from .s2t_dualinputtransformer import DualInputEncoder, DualInputS2TTransformerModel, TransformerMultiInputDecoder
label_desc: Use image node_id 7 for calling the DualInputWavTransformerModel obj's underlying member method code with example usage: obj.build_encoder(cls, args, task) and returns: encoder