class_docstr: A subclass which adds words prediction to RNN arch.
class_docstr_tok: ["A","subclass","which","adds","words","prediction","to","RNN","arch","."]
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."""
      src_dict, dst_dict = (
          task.source_dictionary,
          task.target_dictionary,
      )
      base_architecture_wp(args)
  
      (
          encoder_embed_tokens,
          decoder_embed_tokens,
      ) = RNNModel.build_embed_tokens(args, src_dict, dst_dict)
  
      if args.sequence_lstm:
          encoder_class = LSTMSequenceEncoder
      else:
          encoder_class = RNNEncoder
      decoder_class = RNNDecoder
  
      encoder = encoder_class(
          src_dict,
          embed_tokens=encoder_embed_tokens,
          embed_dim=args.encoder_embed_dim,
          cell_type=args.cell_type,
          num_layers=args.encoder_layers,
          hidden_dim=args.encoder_hidden_dim,
          dropout_in=args.encoder_dropout_in,
          dropout_out=args.encoder_dropout_out,
          residual_level=args.residual_level,
          bidirectional=bool(args.encoder_bidirectional),
      )
      predictor = word_predictor.WordPredictor(
          encoder_output_dim=args.encoder_hidden_dim,
          hidden_dim=args.predictor_hidden_dim,
          output_dim=len(dst_dict),
          topk_labels_per_source_token=args.topk_labels_per_source_token,
      )
      decoder = decoder_class(
          src_dict=src_dict,
          dst_dict=dst_dict,
          embed_tokens=decoder_embed_tokens,
          vocab_reduction_params=args.vocab_reduction_params,
          encoder_hidden_dim=args.encoder_hidden_dim,
          embed_dim=args.decoder_embed_dim,
          out_embed_dim=args.decoder_out_embed_dim,
          cell_type=args.cell_type,
          num_layers=args.decoder_layers,
          hidden_dim=args.decoder_hidden_dim,
          attention_type=args.attention_type,
          dropout_in=args.decoder_dropout_in,
          dropout_out=args.decoder_dropout_out,
          residual_level=args.residual_level,
          averaging_encoder=args.averaging_encoder,
          predictor=None
          if args.topk_labels_per_source_token is None
          else predictor,
      )
  
      return cls(task, encoder, decoder, predictor)
  
file_path: translate/pytorch_translate/word_prediction/word_prediction_model.py
imports: from fairseq.models import FairseqEncoderDecoderModel, register_model, register_model_architecture
  from pytorch_translate import rnn
  from pytorch_translate.rnn import LSTMSequenceEncoder, RNNDecoder, RNNEncoder, RNNModel
  from pytorch_translate.utils import torch_find
  from pytorch_translate.word_prediction import word_predictor
label_desc: Use image node_id 2 for calling the RNNWordPredictionModel obj's underlying member method code with example usage: obj.build_model(cls, args, task) and returns: cls