code: def get_preds_for_single_tagging_task(
      task,
      test_dataloader,
      runner: jiant_runner.JiantRunner,
      verbose: str = True,
  ):
      """Generate predictions for a single tagging task"""
      jiant_model, device = runner.model, runner.device
      jiant_model.eval()
      test_examples = task.get_test_examples()
      preds_list = []
      example_i = 0
      for step, (batch, batch_metadata) in enumerate(
          maybe_tqdm(
              test_dataloader,
              desc=f"Eval ({task.name}, Test)",
              verbose=verbose,
          )
      ):
          batch = batch.to(device)
  
          with torch.no_grad():
              model_output = wrap_jiant_forward(
                  jiant_model=jiant_model,
                  batch=batch,
                  task=task,
                  compute_loss=False,
              )
          batch_logits = model_output.logits.detach().cpu().numpy()
          label_mask_arr = batch.label_mask.cpu().bool().numpy()
          preds_arr = np.argmax(batch_logits, axis=-1)
          for i in range(len(batch)):
              # noinspection PyUnresolvedReferences
              labels = [
                  task.ID_TO_LABEL[class_i]
                  for class_i in preds_arr[i][label_mask_arr[i]]
              ]
              if len(labels) == len(test_examples[example_i].tokens):
                  this_preds = list(
                      zip(test_examples[example_i].tokens, labels)
                  )
              elif len(labels) < len(test_examples[example_i].tokens):
                  this_preds = list(
                      zip(test_examples[example_i].tokens, labels)
                  )
                  this_preds += [
                      (task.LABELS[-1], token)
                      for token in test_examples[example_i].tokens[
                          len(labels) :
                      ]
                  ]
              else:
                  raise RuntimeError
  
              preds_list.append(this_preds)
              example_i += 1
      return preds_list
  
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 4 for calling a global function with example usage: get_preds_for_single_tagging_task(task, test_dataloader, runner, verbose) and returns: preds_list