code: def generate_and_write_preds_for_tagging(
      runner: jiant_runner.JiantRunner,
      supertask: str,
      output_dir: str,
      skip_if_done: bool = False,
  ):
      """Generate and write test predictions for tagging 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_dataloader_dict = runner.get_test_dataloader_dict()
      preds_output_dir = os.path.join(output_dir, "preds", supertask)
      os.makedirs(preds_output_dir, exist_ok=True)
      preds_dict = {}
      for (
          task_name
      ) in runner.jiant_task_container.task_run_config.test_task_list:
          task = runner.jiant_task_container.task_dict[task_name]
          assert isinstance(task, (tasks.UdposTask, tasks.PanxTask))
          preds_list = get_preds_for_single_tagging_task(
              task=task,
              test_dataloader=test_dataloader_dict[task_name],
              runner=runner,
          )
          preds_dict[task_name] = preds_list
          lang = task.language
          with open(
              os.path.join(preds_output_dir, f"test-{lang}.tsv"), "w"
          ) as f:
              for example_preds in preds_list:
                  for word, label in example_preds:
                      f.write(f"{label}\n")
                  f.write("\n")
      torch.save(preds_dict, preds_pickle_path)
      print(
          f"Wrote {supertask} preds for"
          f" {len(runner.jiant_task_container.task_run_config.test_task_list)} 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 3 for calling a global function with example usage: generate_and_write_preds_for_tagging(runner, supertask, output_dir, skip_if_done) without return types