docstr: Build a new model instance.
code: def build_model(cls, args, task):
      """Build a new model instance."""
  
      # make sure all arguments are present in older models
      base_architecture(args)
      if (
          getattr(args, "load_pretrained_decoder_from", None)
          is not None
      ):
          ckpt = torch.load(
              getattr(args, "load_pretrained_decoder_from", None)
          )
          decoder_args_dict = cls.get_decoder_args_from_checkpoint(
              ckpt["cfg"]
          )
          args = cls.override_decoder_args(args, decoder_args_dict)
  
      decoder_embed_tokens = build_embedding(
          task.target_dictionary, args.decoder_embed_dim
      )
  
      encoder = cls.build_encoder(args)
      decoder = cls.build_decoder(args, task, decoder_embed_tokens)
      base_model = cls(encoder, decoder)
  
      # set up multitask decoders
      base_model.multitask_decoders = {}
      for i, (task_name, task_obj) in enumerate(
          task.multitask_tasks.items()
      ):
          # dummy auxiliary decoder
          if task_obj.args.get_loss_weight(0) == 0:
              continue
  
          task_decoder = cls.build_multitask_decoder(
              args,
              task_obj.args,
              task_obj.target_dictionary,
              args.decoder_embed_dim,
          )
  
          setattr(base_model, f"{task_name}_decoder", task_decoder)
          decoder_model_cls = (
              FairseqEncoderModel
              if task_obj.args.decoder_type == "ctc"
              else FairseqLanguageModel
          )
          base_model.multitask_decoders[task_name] = decoder_model_cls(
              getattr(base_model, f"{task_name}_decoder")
          )
      return base_model
  
imports: import copy
  import logging
  from typing import Dict, List, Optional, Tuple
  import numpy
  import torch
  import torch.nn
  from torch import Tensor
  from fairseq import checkpoint_utils, utils
  from fairseq.data.data_utils import lengths_to_padding_mask
  from fairseq.models import FairseqEncoder, FairseqEncoderDecoderModel, FairseqEncoderModel, FairseqLanguageModel, register_model, register_model_architecture
  from fairseq.models.speech_to_speech.modules.ctc_decoder import CTCDecoder
  from fairseq.models.speech_to_text.hub_interface import S2THubInterface
  from fairseq.models.transformer import Embedding, TransformerDecoder, TransformerModelBase
  from fairseq.models.wav2vec import Wav2VecEncoder
  from fairseq.modules.layer_norm import LayerNorm
label_desc: Use image node_id 10 for calling the XMTransformerModel obj's underlying member method code with example usage: obj.build_model(cls, args, task) and returns: base_model