code: def generate_and_write_preds_for_classification(
      runner: jiant_runner.JiantRunner,
      supertask: str,
      output_dir: str,
      skip_if_done: bool = False,
  ):
      """Write test predictions for classification tasks in XTREME submission format"""
      preds_pickle_path = os.path.join(
          output_dir, f"{supertask}_test_preds.p"
      )
      if skip_if_done and os.path.exists(preds_pickle_path):
          print(f"Skipping cause {preds_pickle_path} exists")
          return
  
      test_results_dict = runner.run_test(
          task_name_list=runner.jiant_task_container.task_run_config.test_task_list,
      )
      jiant_evaluate.write_preds(
          eval_results_dict=test_results_dict,
          path=preds_pickle_path,
      )
      preds_output_dir = os.path.join(output_dir, "preds", supertask)
      os.makedirs(preds_output_dir, exist_ok=True)
      for task_name, task_results in test_results_dict.items():
          task = runner.jiant_task_container.task_dict[task_name]
          assert isinstance(task, (tasks.XnliTask, tasks.PawsXTask))
          lang = task.language
          with open(
              os.path.join(preds_output_dir, f"test-{lang}.tsv"), "w"
          ) as f:
              for idx in task_results["preds"]:
                  if supertask == "xnli":
                      pred_label = task.ID_TO_LABEL[idx]
                  elif supertask == "pawsx":
                      pred_label = idx
                  else:
                      raise RuntimeError()
                  f.write(f"{pred_label}\n")
      print(
          f"Wrote {supertask} preds for {len(test_results_dict)} languages"
      )
  
imports: import os
  import numpy
  import torch
  import zconf
  import jiant.utils.python.io
  from jiant.utils.display import maybe_tqdm
  import jiant.shared.initialization
  import jiant.shared.model_resolution
  import jiant.proj.main.components.container_setup
  import jiant.proj.main.runner
  from jiant.proj.main.runscript import setup_runner
  import jiant.tasks.lib.templates.squad_style.core
  import jiant.tasks.lib.bucc2018
  import jiant.tasks
  import jiant.proj.main.components.evaluate
  from jiant.proj.main.modeling.primary import wrap_jiant_forward
label_desc: Use image node_id 2 for calling a global function with example usage: generate_and_write_preds_for_classification(runner, supertask, output_dir, skip_if_done) without return types