class_docstr: Model described in (https://arxiv.org/abs/1811.00945).
  
  A model for producing engaging captions about an image. Given an image and
  this model will attempt to predict an appropriate
  next utterance in the dialog, in the context of a given personality.
  
  See the paper linked above for more information.
class_docstr_tok: ["Model","described","in","(","https",":","\/\/arxiv.org\/abs\/1811.00945",")",".","A","model","for","producing","engaging","captions","about","an","image",".","Given","an","image","and","this","model","will","attempt","to","predict","an","appropriate","next","utterance","in","the","dialog",",","in","the","context","of","a","given","personality",".","See","the","paper","linked","above","for","more","information","."]
code: def _setup_cands(self):
      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(None, None, batch)[1].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.core.agents import Agent
  from parlai.core.dict import DictionaryAgent
  from parlai.utils.misc import round_sigfigs
  from .modules import TransresnetModel
  from parlai.tasks.personality_captions.build import build
  from parlai.utils.io import PathManager
  import parlai.utils.torch
  import os
  import random
  import json
  import numpy
  import torch
  import tqdm
label_desc: Use image node_id 6 for calling the TransresnetAgent obj's underlying member method code with example usage: obj._setup_cands() without return types