code: def get_predictions(
      model, data_gen, replace_word=None, round_res=False
  ):
      """Gets model predictions and replaces model output with replace_word.
  
      Args:
          model: The model itself.
          data_gen: Iterator with data to be submitted.
          replace_word: Model outputs to be replaced with 1, other outputs are replaced with 0.
              If None, model outputs are not replaced.
          round_res: If True, model outputs are rounded (used in stsb).
      """
  
      submission = {"index": [], "prediction": []}
      for idx, (x, _) in enumerate(tqdm(data_gen)):
          prediction = model.compute(x)[0]
          if replace_word:
              prediction = 1 if prediction == replace_word else 0
          if round_res:
              prediction = round(prediction, 3)
          submission["index"].append(idx)
          submission["prediction"].append(prediction)
      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 2 for calling a global function with example usage: get_predictions(model, data_gen, replace_word, round_res) and returns: submission