class_docstr: Model from "Engaging Image Chat: Modeling Personality in Grounded Dialogue".
  
  See paper for more details: (https://arxiv.org/abs/1811.00945)
  
  An extension of the model from https://arxiv.org/abs/1810.10665; given
  an image, personality, and dialogue history, predicts the next utterance
  in a dialogue.
class_docstr_tok: ["Model","from","``","Engaging","Image","Chat",":","Modeling","Personality","in","Grounded","Dialogue","''",".","See","paper","for","more","details",":","(","https",":","\/\/arxiv.org\/abs\/1811.00945",")","An","extension","of","the","model","from","https",":","\/\/arxiv.org\/abs\/1810.10665",";","given","an","image",",","personality",",","and","dialogue","history",",","predicts","the","next","utterance","in","a","dialogue","."]
docstr: Override for different call to model.
docstr_tok: ["Override","for","different","call","to","model","."]
code: def _setup_cands(self):
      """
      Override for different call to model.
      """
      self.fixed_cands = None
      self.fixed_cands_enc = None
      if self.fcp is not None:
          with PathManager.open(self.fcp) as f:
              self.fixed_cands = [
                  c.replace("\n", "") for c in f.readlines()
              ]
          cands_enc_file = "{}.cands_enc".format(self.fcp)
          print("loading saved cand encodings")
          if PathManager.exists(cands_enc_file):
              with PathManager.open(cands_enc_file, "rb") as f:
                  self.fixed_cands_enc = torch.load(
                      f, map_location=lambda cpu, _: cpu
                  )
          else:
              print("Extracting cand encodings")
              self.model.eval()
              pbar = tqdm.tqdm(
                  total=len(self.fixed_cands),
                  unit="cand",
                  unit_scale=True,
                  desc="Extracting candidate encodings",
              )
              fixed_cands_enc = []
              for _, batch in enumerate(
                  [
                      self.fixed_cands[i : i + 50]
                      for i in range(0, len(self.fixed_cands) - 50, 50)
                  ]
              ):
                  embedding = self.model.forward_text_encoder(
                      batch
                  ).detach()
                  fixed_cands_enc.append(embedding)
                  pbar.update(50)
              self.fixed_cands_enc = torch.cat(fixed_cands_enc, 0)
              torch_utils.atomic_save(
                  self.fixed_cands_enc, cands_enc_file
              )
  
imports: from typing import Optional
  from parlai.core.params import ParlaiParser
  from parlai.core.opt import Opt
  from parlai.utils.misc import round_sigfigs
  from parlai.core.message import Message
  from .modules import TransresnetMultimodalModel
  from projects.personality_captions.transresnet.transresnet import TransresnetAgent
  from parlai.utils.io import PathManager
  import parlai.utils.torch
  import torch
  from torch import optim
  import random
  import numpy
  import tqdm
  from collections import deque
label_desc: Use image node_id 4 for calling the TransresnetMultimodalAgent obj's underlying member method code with example usage: obj._setup_cands() without return types