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 answerf 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
docs: Generate json by prediction.