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 generate_knowledge_observation(
      self, knowledges: List[str], observations
  ):
      # Adjust the observation texts.
      knowledge_infused_observations = deepcopy(observations)
      for obs, knowledge in zip(
          knowledge_infused_observations, knowledges
      ):
          if "text" not in obs:
              continue
          text = obs.pop("text")
  
          if self.opts["init"]["add_fixed_confidence"] >= 0:
              confidence = self.opts["init"]["add_fixed_confidence"]
              if self.opts["init"]["add_confidence_as_str"]:
                  confidence = {
                      0: "low",
                      5: "medium",
                      10: "high",
                  }[confidence] + " confidence"
              text += f"\n{TOKEN_KNOWLEDGE} {confidence}: {knowledge} {TOKEN_END_KNOWLEDGE}"
          else:
              text += f"\n{TOKEN_KNOWLEDGE} {knowledge} {TOKEN_END_KNOWLEDGE}"
          obs["text"] = text
      return knowledge_infused_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 12 for calling the StackedKnowledgeDialogueAgent obj's underlying member method code with example usage: obj.generate_knowledge_observation(knowledges, observations) and returns: knowledge_infused_observations