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: Get dialogue history for an observation.
  
  :param obs:
      observation
  
  :return:
      the observation with the dialogue history in the `text` field
docstr_tok: ["Get","dialogue","history","for","an","observation",".",":","param","obs",":","observation",":","return",":","the","observation","with","the","dialogue","history","in","the","`","text","`","field"]
code: def get_dialogue_history(self, obs):
      """
      Get dialogue history for an observation.
  
      :param obs:
          observation
  
      :return:
          the observation with the dialogue history in the `text` field
      """
      if len(self.history) > 0:
          obs.force_set(
              "text", "\n".join(self.history) + "\n" + obs["text"]
          )
      if "labels" in obs:
          self.history.append(random.choice(obs["labels"]))
      elif "eval_labels" in obs:
          self.history.append(random.choice(obs["eval_labels"]))
      if obs.get("episode_done", True):
          # end of this episode, clear the history
          self.history.clear()
  
      return obs
  
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 11 for calling the TransresnetMultimodalAgent obj's underlying member method code with example usage: obj.get_dialogue_history(obs) and returns: obs