code: def generate_predict_json(
      position1_result, position2_result, ids, passage_tokens
  ):
      """
      Generate json by prediction.
      """
      predict_len = len(position1_result)
      logger.debug("total prediction num is %s", str(predict_len))
  
      answers = {}
      for i in range(predict_len):
          sample_id = ids[i]
          passage, tokens = passage_tokens[i]
          kbest = find_best_answer_span(
              position1_result[i], position2_result[i], len(tokens), 23
          )
          _, start, end = kbest[0]
          answer = passage[
              tokens[start]["char_begin"] : tokens[end]["char_end"]
          ]
          answers[sample_id] = answer
      logger.debug("generate predict done.")
      return answers
  
imports: import argparse
  import heapq
  import json
  import os
  import pickle
  import logging
  import numpy
  from tensorflow.train import init_from_checkpoint
  import graph
  from util import Timer
  import nni
  import data
  import evaluate
  from train_model import *
label_desc: Use image node_id 8 for calling a global function with example usage: generate_predict_json(position1_result, position2_result, ids, passage_tokens) and returns: answers