class_docstr: Stacked model that generates first the knowledge, and then the dialogue response.
class_docstr_tok: ["Stacked","model","that","generates","first","the","knowledge",",","and","then","the","dialogue","response","."]
code: def observe(self, observation):
      # Delete unused keys.
      for key in ["label_candidates", "knowledge"]:
          if key in observation:
              del observation[key]
  
      label_key = (
          "eval_labels" if "eval_labels" in observation else "labels"
      )
      if "nqopen" in self.opts["init"]["task"].lower():
          knowledge_target = observation.get(label_key, "")
          if isinstance(knowledge_target, tuple):
              knowledge_target = "\t".join(knowledge_target)
          observation["knowledge_target"] = knowledge_target
          observation["dialogue_response"] = ""
      else:
          observation["dialogue_response"] = observation.get(
              label_key, ""
          )
          observation["knowledge_response"] = observation.get(
              "checked_sentence", ""
          )
  
      if self.knowledge_agent is None:
          self._init_knowledge_model()
  
      observations = {
          "raw": deepcopy(observation),
          "knowledge_agent": self.knowledge_agent.observe(observation),
      }
      self.observations = observations
      return observations
  
imports: from copy import deepcopy
  from typing import Optional, List
  from types import MethodType
  from collections import defaultdict
  from nltk.tokenize import sent_tokenize
  from nltk.corpus import stopwords
  import random
  import spacy
  import torch
  from parlai.core.agents import create_agent, create_agent_from_shared
  from parlai.core.params import ParlaiParser
  from parlai.core.opt import Opt
  from parlai.core.message import Message
  from parlai.core.agents import Agent
  from parlai.core.metrics import F1Metric
  from parlai.agents.rag.args import setup_rag_args
  from parlai.agents.bart.bart import BartAgent
  from parlai.core.metrics import normalize_answer
  from parlai.tasks.wizard_of_wikipedia.agents import TOKEN_NOCHOSEN
  from parlai.tasks.wizard_of_wikipedia.agents import TOKEN_KNOWLEDGE, TOKEN_END_KNOWLEDGE
label_desc: Use image node_id 16 for calling the StackedKnowledgeDialogueAgent obj's underlying member method code with example usage: obj.observe(observation) and returns: observations