docstr: Build a new model instance.
docstr_tok: ["Build","a","new","model","instance","."]
code: def build_model(cls, args, task):
      """Build a new model instance."""
  
      from omegaconf import OmegaConf
  
      if OmegaConf.is_config(args):
          OmegaConf.set_struct(args, False)
  
      # make sure all arguments are present
      base_architecture(args)
  
      if not hasattr(args, "max_positions"):
          if not hasattr(args, "tokens_per_sample"):
              args.tokens_per_sample = task.max_positions()
          args.max_positions = args.tokens_per_sample
  
      encoder = XMODEncoder(args, task.source_dictionary)
  
      if OmegaConf.is_config(args):
          OmegaConf.set_struct(args, True)
  
      return cls(args, encoder)
  
imports: from ..roberta.model_xlmr import XLMRModel
  from fairseq.models.xmod.transformer_layer_xmod import XMODTransformerEncoderLayerBase
  from ..roberta.model import base_architecture, RobertaEncoder
  from fairseq.models.transformer import TransformerEncoder
  from fairseq.modules.transformer_sentence_encoder import init_bert_params
  from typing import Optional
  from fairseq.models.xmod.hub_interface import XMODHubInterface
  import torch
  from fairseq.distributed import fsdp_wrap
  from fairseq.models import register_model, register_model_architecture
  from fairseq.modules.checkpoint_activations import checkpoint_wrapper
label_desc: Use image node_id 3 for calling the XMODModel obj's underlying member method code with example usage: obj.build_model(cls, args, task) and returns: cls