docstr: Construct a UnigramAgent.
  
  :param opt: parlai options
  :param shared: Used to duplicate the model for batching/hogwild.
docstr_tok: ["Construct","a","UnigramAgent",".",":","param","opt",":","parlai","options",":","param","shared",":","Used","to","duplicate","the","model","for","batching\/hogwild","."]
code: def __init__(self, opt, shared=None):
      """
      Construct a UnigramAgent.
  
      :param opt: parlai options
      :param shared: Used to duplicate the model for batching/hogwild.
      """
      self.id = "UnigramAgent"
      self.unigram_cache = None
      self.opt = opt
      self.num_words = opt["num_words"]
  
      if shared is not None:
          self.dict = shared["dict"]
      else:
          self.dict = self.dictionary_class()(opt)
  
imports: from typing import Optional
  from parlai.core.params import ParlaiParser
  from parlai.core.opt import Opt
  import json
  import re
  from parlai.core.agents import Agent
  from parlai.core.dict import DictionaryAgent
  from itertools import islice
  from parlai.utils.io import PathManager
label_desc: Use image node_id 3 to create a new UnigramAgent object from inherited base classes: Agent with example: obj = UnigramAgent(opt, shared)