class_docstr: A training module for NER. See BaseTransformer for the core options.
code: def __init__(self, hparams):
      if isinstance(hparams, dict):
          hparams = Namespace(**hparams)
      module = import_module("tasks")
      try:
          token_classification_task_clazz = getattr(
              module, hparams.task_type
          )
          self.token_classification_task: TokenClassificationTask = (
              token_classification_task_clazz()
          )
      except AttributeError:
          raise ValueError(
              f"Task {hparams.task_type} needs to be defined as a TokenClassificationTask subclass in {module}. "
              f"Available tasks classes are: {TokenClassificationTask.__subclasses__()}"
          )
      self.labels = self.token_classification_task.get_labels(
          hparams.labels
      )
      self.pad_token_label_id = CrossEntropyLoss().ignore_index
      super().__init__(hparams, len(self.labels), self.mode)
  
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 1 to create a new NERTransformer object from inherited base classes: BaseTransformer with example: obj = NERTransformer(hparams)