class_docstr: Extension of Transresnet to incorporate dialogue history and multimodality.
docstr: Build the context (i.e. dialogue history) encoder.
docstr_tok: ["Build","the","context","(","i.e",".","dialogue","history",")","encoder","."]
code: def _build_context_encoder(self):
      """
      Build the context (i.e. dialogue history) encoder.
      """
      if self.opt.get("share_encoder"):
          self.context_encoder = self.label_encoder
      else:
          if (
              self.opt["load_context_encoder_from"] is None
              and self.opt["context_encoder_embedding_type"]
              == "fasttext_cc"
          ):
              embeddings = load_fasttext_embeddings(
                  self.dictionary,
                  self.opt["embedding_size"],
                  self.opt["datapath"],
              )
          else:
              embeddings = nn.Embedding(
                  len(self.dictionary), self.opt["embedding_size"]
              )
          self.context_encoder = TransformerEncoder(
              opt=self.opt,
              embedding=embeddings,
              vocabulary_size=len(self.dictionary),
              padding_idx=self.dictionary.tok2ind[
                  self.dictionary.null_token
              ],
              embeddings_scale=False,
              output_scaling=1.0,
          )
          if self.opt.get("load_context_encoder_from") is not None:
              self._load_context_encoder_state()
  
imports: from typing import Optional
  from parlai.core.params import ParlaiParser
  from parlai.core.opt import Opt
  import torch
  from torch import nn
  from parlai.utils.io import PathManager
  from parlai.agents.transformer.modules import TransformerEncoder, create_position_codes, TransformerEncoderLayer
  from projects.personality_captions.transresnet.modules import TransresnetModel, load_fasttext_embeddings
label_desc: Use image node_id 4 for calling the TransresnetMultimodalModel obj's underlying member method code with example usage: obj._build_context_encoder() without return types