code: def convert_msmarco_to_squad_format(msmarco_data, args):
      ids = list(msmarco_data["query"])
      squad_data = {
          "data": [{"title": "MSMARCO", "paragraphs": []}],
          "version": "v2.1",
      }
      for index, _id in enumerate(tqdm(ids)):
          context = get_context_from_passages(
              msmarco_data["passages"][_id],
              args.keep_only_relevant_passages,
          )
          if not context:
              continue
  
          query = msmarco_data["query"][_id]
  
          # use well formed answers if present, else use the 'answers' field
          well_formed_answers = msmarco_data["wellFormedAnswers"][_id]
          well_formed_answers = (
              well_formed_answers
              if isinstance(well_formed_answers, list)
              else literal_eval(well_formed_answers)
          )
          answers = (
              well_formed_answers
              if well_formed_answers
              else msmarco_data["answers"][_id]
          )
          answers = format_answers_into_squad_format(answers)
          if args.exclude_negative_samples and (not answers):
              continue
  
          squad_data["data"][0]["paragraphs"].append(
              {
                  "context": context,
                  "qas": [
                      {
                          "id": index,
                          "question": query,
                          "answers": answers,
                          "is_impossible": False if answers else True,
                      }
                  ],
              }
          )
  
      return squad_data
  
file_path: NeMo/examples/nlp/question_answering/convert_msmarco_to_squad_format.py
imports: import argparse
  import json
  from ast import literal_eval
  from tqdm import tqdm
label_desc: Use image node_id 5 for calling a global function with example usage: convert_msmarco_to_squad_format(msmarco_data, args) and returns: squad_data