code: def write_squad_predictions(
      predictions, out_filename, predictions_filename=None
  ):
      predictions_json = {}
      for x in predictions:
          for p in x["predictions"]:
              if p["answers"][0]["answer"] is not None:
                  predictions_json[p["question_id"]] = p["answers"][0][
                      "answer"
                  ]
              else:
                  predictions_json[
                      p["question_id"]
                  ] = ""  # convert No answer = None to format understood by the SQuAD eval script
  
      if predictions_filename:
          dev_labels = {}
          temp = json.load(open(predictions_filename, "r"))
          for d in temp["data"]:
              for p in d["paragraphs"]:
                  for q in p["qas"]:
                      if q.get("is_impossible", False):
                          dev_labels[q["id"]] = "is_impossible"
                      else:
                          dev_labels[q["id"]] = q["answers"][0]["text"]
          not_included = set(list(dev_labels.keys())) - set(
              list(predictions_json.keys())
          )
          if len(not_included) > 0:
              logger.info(
                  f"There were missing predicitons for question ids: {list(not_included)}"
              )
          for x in not_included:
              predictions_json[x] = ""
  
      # os.makedirs("model_output", exist_ok=True)
      # filepath = Path("model_output") / out_filename
      json.dump(predictions_json, open(out_filename, "w"))
      logger.info(f"Written Squad predictions to: {out_filename}")
  
imports: import hashlib
  import json
  import logging
  import os
  import random
  import tarfile
  import tempfile
  import string
  import uuid
  from contextlib import ExitStack
  from itertools import islice
  from pathlib import Path
  import pandas
  from requests import get
  from tqdm import tqdm
  from typing import List
  from farm.file_utils import http_get
  from farm.modeling.tokenization import tokenize_with_metadata
label_desc: Use image node_id 9 for calling a global function with example usage: write_squad_predictions(predictions, out_filename, predictions_filename) without return types