class_docstr: A training module for NER. See BaseTransformer for the core options.
docstr: Evaluation called for both Val and Test
docstr_tok: ["Evaluation","called","for","both","Val","and","Test"]
code: def _eval_end(self, outputs):
      "Evaluation called for both Val and Test"
      val_loss_mean = torch.stack(
          [x["val_loss"] for x in outputs]
      ).mean()
      preds = np.concatenate([x["pred"] for x in outputs], axis=0)
      preds = np.argmax(preds, axis=2)
      out_label_ids = np.concatenate(
          [x["target"] for x in outputs], axis=0
      )
  
      label_map = dict(enumerate(self.labels))
      out_label_list = [[] for _ in range(out_label_ids.shape[0])]
      preds_list = [[] for _ in range(out_label_ids.shape[0])]
  
      for i in range(out_label_ids.shape[0]):
          for j in range(out_label_ids.shape[1]):
              if out_label_ids[i, j] != self.pad_token_label_id:
                  out_label_list[i].append(
                      label_map[out_label_ids[i][j]]
                  )
                  preds_list[i].append(label_map[preds[i][j]])
  
      results = {
          "val_loss": val_loss_mean,
          "accuracy_score": accuracy_score(out_label_list, preds_list),
          "precision": precision_score(out_label_list, preds_list),
          "recall": recall_score(out_label_list, preds_list),
          "f1": f1_score(out_label_list, preds_list),
      }
  
      ret = dict(results.items())
      ret["log"] = results
      return ret, preds_list, out_label_list
  
imports: import argparse
  import glob
  import logging
  import os
  from argparse import Namespace
  from importlib import import_module
  import numpy
  import torch
  from lightning_base import BaseTransformer, add_generic_args, generic_train
  from seqeval.metrics import accuracy_score, f1_score, precision_score, recall_score
  from torch.nn import CrossEntropyLoss
  from torch.utils.data import DataLoader, TensorDataset
  from utils_ner import TokenClassificationTask
label_desc: Use image node_id 7 for calling the NERTransformer obj's underlying member method code with example usage: obj._eval_end(outputs) and returns: ret,  preds_list,  out_label_list