code: def convert_qa_input_dict(infer_dict):
      """Input dictionaries in QA can either have ["context", "qas"] (internal format) as keys or
      ["text", "questions"] (api format). This function converts the latter into the former. It also converts the
      is_impossible field to answer_type so that NQ and SQuAD dicts have the same format.
      """
      try:
          # Check if infer_dict is already in internal json format
          if "context" in infer_dict and "qas" in infer_dict:
              return infer_dict
          # converts dicts from inference mode to data structure used in FARM
          questions = infer_dict["questions"]
          text = infer_dict["text"]
          uid = infer_dict.get("id", None)
          qas = [
              {
                  "question": q,
                  "id": uid,
                  "answers": [],
                  "answer_type": None,
              }
              for i, q in enumerate(questions)
          ]
          converted = {"qas": qas, "context": text}
          return converted
      except KeyError:
          raise Exception("Input does not have the expected format")
  
file_path: FARM/farm/data_handler/nq_utils.py
imports: import logging
  import re
  import numpy
  from farm.data_handler.samples import Sample
label_desc: Use image node_id 11 for calling a global function with example usage: convert_qa_input_dict(infer_dict) and returns: converted, infer_dict