code: def parse_drop(fn, reasoning, savefile):
      json_lines = []
      reasonings = {}
      with open(reasoning, "r") as f:
          json_lines = json.load(f)
          print(len(json_lines))
  
      for json_line in json_lines:
          reasonings[json_line["key"]] = json_line
  
      structs = []
  
      with open(fn, "r") as json_file:
          alldata = json.load(json_file)
  
          for k, v in alldata.items():
              questions = v["qa_pairs"]
              count = 0
              for q in questions:
                  struct = {}
                  count += 1
                  question = q["question"]
                  answer = q["answer"]
                  number = answer["number"]
                  span = answer["spans"]
                  if len(number) > 0:
                      struct["key"] = k + "\t" + q["query_id"]
                      if len(v["passage"].split(" ")) < 200:
                          struct["premise"] = v["passage"]
                          struct["premise"] = (
                              v["passage"] + " " + question
                          )
                          struct["hypothesis"] = number
                          struct["answer"] = "yes"
                  elif len(span) > 0:
                      struct["key"] = k + "\t" + q["query_id"]
                      if len(v["passage"].split(" ")) < 200:
                          struct["premise"] = v["passage"]
                          struct["premise"] = (
                              v["passage"] + " " + question
                          )
                          struct["hypothesis"] = span[0]
                          struct["answer"] = "yes"
  
                  if "premise" in struct:
                      if struct["key"] in reasonings:
                          reasoning = reasonings[struct["key"]][
                              "reasoning"
                          ]
                          struct["gpt-3"] = reasoning
                          structs.append(struct)
                      else:
                          val = struct["key"]
                          print(f"No reasoning found for key {val}")
  
                  if count > 2:
                      break
  
              ## we used the first 250 of these
              if len(structs) > 250:
                  break
  
      write_to_file(structs, savefile)
  
file_path: ParlAI/projects/roscoe/roscoe_data/restore_annotated.py
imports: import json
  import csv
  import os
  import re
  import xmltodict
  from parlai.core.params import ParlaiParser
label_desc: Use image node_id 2 for calling a global function with example usage: parse_drop(fn, reasoning, savefile) without return types