code: def multi_sentence_comprehension_prediction(model, data_gen):
      """Common part for MultiRC and MuSeRC tasks that gets their predictions in needed format.
  
      Args:
          model: The model itself.
          data_gen: Iterator with data to be submitted.
      """
  
      output = {}
  
      for x, _ in tqdm(data_gen):
          contexts, answers, indices = x[0]
  
          prediction = model([contexts], [answers], indices)
  
          paragraph_idx = indices["paragraph"]
          question_idx = indices["question"]
          answer_idx = indices["answer"]
  
          label = int(prediction[0] == "True")
          if paragraph_idx not in output:
              output[paragraph_idx] = {
                  "idx": paragraph_idx,
                  "passage": {
                      "questions": [
                          {
                              "idx": question_idx,
                              "answers": [
                                  {"idx": answer_idx, "label": label}
                              ],
                          }
                      ]
                  },
              }
  
          questions = output[paragraph_idx]["passage"]["questions"]
          question_indices = set(el["idx"] for el in questions)
          if question_idx not in question_indices:
              output[paragraph_idx]["passage"]["questions"].append(
                  {
                      "idx": question_idx,
                      "answers": [{"idx": answer_idx, "label": label}],
                  }
              )
          else:
              for question in questions:
                  if question["idx"] == question_idx:
                      question["answers"].append(
                          {"idx": answer_idx, "label": label}
                      )
  
      submission = list(output.values())
      return submission
  
file_path: DeepPavlov/deeppavlov/utils/benchmarks/benchmarks.py
imports: import argparse
  from collections import defaultdict
  from logging import getLogger
  import numpy
  from tqdm import tqdm
  from deeppavlov import build_model
  from deeppavlov.core.commands.train import read_data_by_config, get_iterator_from_config
  from deeppavlov.core.commands.utils import parse_config, expand_path
  from deeppavlov.core.common.file import save_jsonl
label_desc: Use image node_id 5 for calling a global function with example usage: multi_sentence_comprehension_prediction(model, data_gen) and returns: submission