code: def create_fb_format(outpath, dtype, inpath):
      print("building fbformat:" + dtype)
      fout = open(os.path.join(outpath, dtype + ".txt"), "w")
      with PathManager.open(inpath) as f:
          lines = [line.strip("\n") for line in f]
      lastqid, lq, ans, cands = None, None, None, None
      for i in range(2, len(lines)):
          l = lines[i].split("\t")
          lqid = l[0]  # question id
          if lqid != lastqid:
              if lastqid is not None:
                  # save
                  s = (
                      "1 "
                      + lq
                      + "\t"
                      + ans.lstrip("|")
                      + "\t\t"
                      + cands.lstrip("|")
                  )
                  if (dtype.find("filtered") == -1) or ans != "":
                      fout.write(s + "\n")
              # reset
              cands = ""
              ans = ""
              lastqid = lqid
          lcand = l[5]  # candidate answer / sentence from doc
          lq = l[1]  # question
          llabel = l[6]  # 0 or 1
          if int(llabel) == 1:
              ans = ans + "|" + lcand
          cands = cands + "|" + lcand
      fout.close()
  
imports: import parlai.core.build_data
  import os
  from parlai.core.build_data import DownloadableFile
  from parlai.utils.io import PathManager
label_desc: Use image node_id 1 for calling a global function with example usage: create_fb_format(outpath, dtype, inpath) without return types