code: def knowledge_from_dialogue_response(dialogue_response: str) -> str:
      """
      Get a knowledge response based on the dialogue response.
  
      We use a random entity from the dialogue response as knowledge. If there is no
      entity present, we use a random word. If there are no words present, we use
      TOKEN_NOCHOSEN.
      """
      knowledge_options = extract_knowledge(dialogue_response)
      if not knowledge_options:
          return TOKEN_NOCHOSEN
      return random.choice(knowledge_options)
  
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 6 for calling a global function with example usage: knowledge_from_dialogue_response(dialogue_response) and returns: random, TOKEN_NOCHOSEN