class_docstr: MutualFriends dataset.
docstr: Load json data of conversations.
docstr_tok: ["Load","json","data","of","conversations","."]
code: def setup_data(self, path):
      """
      Load json data of conversations.
      """
      print("loading: " + path)
      with PathManager.open(path) as data_file:
          self.loaded_data = json.load(data_file)
      for ex in self.loaded_data:
          if len(ex["events"]) > 0:
              # TODO: add reverse conversation as well
              curr_agent = ex["events"][0]["agent"]
              conversation = [
                  (
                      "You have the following friends:\n"
                      + "\n".join(
                          ", ".join(
                              "{}={}".format(k, v)
                              for k, v in person.items()
                          )
                          for person in ex["scenario"]["kbs"][
                              int(curr_agent)
                          ]
                      )
                      + "\nTry to find out which friend the other person has in common."
                  )
              ]
              curr = ""
              idx = 0
              while idx < len(ex["events"]):
                  msg = ex["events"][idx]["data"]
                  if type(msg) == dict:
                      msg = "SELECT({})".format(
                          ", ".join(
                              "{}={}".format(k, v)
                              for k, v in msg.items()
                          )
                      )
                  next_agent = ex["events"][idx]["agent"]
                  if curr_agent == next_agent:
                      curr += "\n" + msg
                      curr = curr.strip()
                  else:
                      conversation.append(curr)
                      curr = msg
                      curr_agent = next_agent
                  idx += 1
              conversation.append(curr)
              for i in range(0, len(conversation), 2):
                  if i + 1 < len(conversation) - 1:
                      yield (
                          conversation[i],
                          [conversation[i + 1]],
                      ), i == 0
                  elif i + 1 == len(conversation) - 1:
                      yield (
                          (
                              conversation[i],
                              [conversation[i + 1]],
                              ex["outcome"],
                          ),
                          False,
                      )
                  else:
                      yield (
                          conversation[i],
                          None,
                          ex["outcome"],
                      ), False
  
file_path: ParlAI/parlai/tasks/mutualfriends/agents.py
imports: from parlai.core.teachers import DialogTeacher
  from parlai.utils.io import PathManager
  from .build import build
  import json
  import os
label_desc: Use image node_id 3 for calling the DefaultTeacher obj's underlying member method code with example usage: obj.setup_data(path) without return types