class_docstr: Agent returns random candidate if available or repeats the label.
docstr: Generate response to last seen observation.
  
  Replies with a randomly selected candidate if label_candidates or a
  candidate file are available.
  Otherwise, replies with the label if they are available.
  Oterhwise, replies with generic hardcoded responses if the agent has
  not observed any messages or if there are no replies to suggest.
  
  :returns: message dict with reply
docstr_tok: ["Generate","response","to","last","seen","observation",".","Replies","with","a","randomly","selected","candidate","if","label_candidates","or","a","candidate","file","are","available",".","Otherwise",",","replies","with","the","label","if","they","are","available",".","Oterhwise",",","replies","with","generic","hardcoded","responses","if","the","agent","has","not","observed","any","messages","or","if","there","are","no","replies","to","suggest",".",":","returns",":","message","dict","with","reply"]
code: def act(self):
      """
      Generate response to last seen observation.
  
      Replies with a randomly selected candidate if label_candidates or a
      candidate file are available.
      Otherwise, replies with the label if they are available.
      Oterhwise, replies with generic hardcoded responses if the agent has
      not observed any messages or if there are no replies to suggest.
  
      :returns: message dict with reply
      """
      obs = self.observation
      if obs is None:
          return {"text": "Nothing to reply to yet."}
      reply = {}
      reply["id"] = self.getID()
      label_candidates = obs.get("label_candidates")
      if hasattr(self, "label_candidates"):
          # override label candidates with candidate file if set
          label_candidates = self.label_candidates
      if label_candidates:
          label_candidates = list(label_candidates)
          random.shuffle(label_candidates)
          reply["text_candidates"] = label_candidates
          reply["text"] = label_candidates[0]
      else:
          # reply with I don't know.
          reply["text"] = "I don't know."
  
      return reply
  
file_path: ParlAI/parlai/agents/random_candidate/random_candidate.py
imports: from typing import Optional
  from parlai.core.params import ParlaiParser
  from parlai.core.opt import Opt
  import random
  from parlai.core.agents import Agent
label_desc: Use image node_id 3 for calling the RandomCandidateAgent obj's underlying member method code with example usage: obj.act() and returns: reply, dict