code: def create_fb_format(outpath, dtype, inpath):
      print("building fbformat:" + dtype)
      episodes = list(convert_file(inpath))
  
      # save the raw json version for span selection task (default)
      with PathManager.open(
          os.path.join(outpath, dtype + ".txt"), "w"
      ) as fout1:
          for ep in episodes:
              fout1.write(json.dumps(ep) + "\n")
  
      # save the file for passage selection task
      with PathManager.open(
          os.path.join(outpath, dtype + ".passage.txt"), "w"
      ) as fout2:
          for dic in episodes:
              lq = dic["query"]
              if dtype != "test":
                  ans = [
                      cleanup(d["passage_text"])
                      for d in dic["passages"]
                      if d["is_selected"] == 1
                  ]
                  if not ans:
                      continue
              else:
                  # ground truth for test data is not available yet
                  ans = []
  
              cands = [
                  cleanup(d["passage_text"]) for d in dic["passages"]
              ]
              if cands and not ans:
                  cands.append("")
              if not cands:
                  continue
              fout2.write(
                  "1 {}\t{}\t\t{}\n".format(
                      lq, "|".join(ans), "|".join(cands)
                  )
              )
  
file_path: ParlAI/parlai/tasks/ms_marco/build.py
imports: import gzip
  import json
  import os
  import tqdm
  import parlai.core.build_data
  from parlai.utils.io import PathManager
  from parlai.core.build_data import DownloadableFile
label_desc: Use image node_id 4 for calling a global function with example usage: create_fb_format(outpath, dtype, inpath) without return types