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 __init__(self, opt, shared=None):
      self.id = "StackedKnowledgeDialogueAgent"
      self._construct_opts(opt)
  
      self.knowledge_agent = None
      self.dialogue_agent = None
      self.dialogue_agent_no_knowledge = None
      self.dialogue_agent_rag_wiki = None
  
      if not shared:
          self._init_knowledge_model()
          self._init_dialogue_models()
      else:
          if "knowledge_agent_share" in shared:
              self.knowledge_agent = create_agent_from_shared(
                  shared["knowledge_agent_share"]
              )
          if "dialogue_agent_share" in shared:
              self.dialogue_agent = create_agent_from_shared(
                  shared["dialogue_agent_share"]
              )
          if "dialogue_agent_no_knowledge_share" in shared:
              self.dialogue_agent = create_agent_from_shared(
                  shared["dialogue_agent_no_knowledge_share"]
              )
          if "dialogue_agent_rag_wiki_share" in shared:
              self.dialogue_agent = create_agent_from_shared(
                  shared["dialogue_agent_rag_wiki_share"]
              )
  
      self.shared = shared
      super().__init__(opt, shared)
  
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 2 to create a new StackedKnowledgeDialogueAgent object from inherited base classes: Agent with example: obj = StackedKnowledgeDialogueAgent(opt, shared)