class_docstr: This version of VisDial inherits from the core Dialog Teacher, which just requires
  it to define an iterator over its data `setup_data` in order to inherit basic
  metrics, a `act` function, and enables Hogwild training with shared memory with no
  extra work.
class_docstr_tok: ["This","version","of","VisDial","inherits","from","the","core","Dialog","Teacher",",","which","just","requires","it","to","define","an","iterator","over","its","data","`","setup_data","`","in","order","to","inherit","basic","metrics",",","a","`","act","`","function",",","and","enables","Hogwild","training","with","shared","memory","with","no","extra","work","."]
code: def setup_data(self, path):
      print("loading: " + path)
      with PathManager.open(path) as data_file:
          self.visdial = json.load(data_file)
  
      self.questions = self.visdial["data"]["questions"]
      self.answers = self.visdial["data"]["answers"]
  
      for dialog in self.visdial["data"]["dialogs"]:
          # for each dialog
          image_id = dialog["image_id"]
          caption = dialog["caption"]
          img_path = self.image_path + "%012d.jpg" % (image_id)
  
          for i, qa in enumerate(dialog["dialog"]):
              # for each question answer pair.
              question = self.questions[qa["question"]]
              answer = [self.answers[qa["answer"]]]
              answer_options = []
              for ans_id in qa["answer_options"]:
                  answer_options.append(self.answers[ans_id])
              if i == 0:
                  # prepend with caption on first question
                  # only load image on first item
                  yield (
                      (
                          caption + "\n" + question,
                          answer,
                          None,
                          answer_options,
                          img_path,
                      ),
                      True,
                  )
              else:
                  yield (question, answer, None, answer_options), False
  
file_path: ParlAI/parlai/tasks/visdial/agents.py
imports: from parlai.core.teachers import DialogTeacher
  from .build import build
  from parlai.utils.io import PathManager
  from parlai.tasks.coco_caption.build_2014 import buildImage
  from PIL import Image
  import json
  import os
label_desc: Use image node_id 2 for calling the DefaultTeacher obj's underlying member method code with example usage: obj.setup_data(path) without return types