class_docstr: Transformer-based (duplex) tagger model for TN/ITN.
docstr: Lightning calls this inside the validation loop with the data from the validation dataloader
  passed in as `batch`.
docstr_tok: ["Lightning","calls","this","inside","the","validation","loop","with","the","data","from","the","validation","dataloader","passed","in","as","`","batch","`","."]
code: def validation_step(self, batch, batch_idx):
      """
      Lightning calls this inside the validation loop with the data from the validation dataloader
      passed in as `batch`.
      """
      # Apply Transformer
      tag_logits = self.forward(
          input_ids=batch["input_ids"],
          attention_mask=batch["attention_mask"],
      )
      tag_preds = torch.argmax(tag_logits, dim=2)
  
      # Update classification_report
      predictions, labels = tag_preds.tolist(), batch["labels"].tolist()
      for prediction, label in zip(predictions, labels):
          cur_preds = [
              p
              for (p, l) in zip(prediction, label)
              if l != constants.LABEL_PAD_TOKEN_ID
          ]
          cur_labels = [
              l
              for (p, l) in zip(prediction, label)
              if l != constants.LABEL_PAD_TOKEN_ID
          ]
          self.classification_report(
              torch.tensor(cur_preds).to(self.device),
              torch.tensor(cur_labels).to(self.device),
          )
  
imports: from time import perf_counter
  from typing import Dict, List, Optional
  import torch
  from omegaconf import DictConfig
  from pytorch_lightning import Trainer
  from torch import nn
  from transformers import AutoModelForTokenClassification, AutoTokenizer, DataCollatorForTokenClassification
  from transformers.tokenization_utils_base import BatchEncoding
  from nemo.collections.nlp.data.text_normalization import TextNormalizationTaggerDataset, constants
  from nemo.collections.nlp.metrics.classification_report import ClassificationReport
  from nemo.collections.nlp.models.duplex_text_normalization.utils import has_numbers
  from nemo.collections.nlp.models.nlp_model import NLPModel
  from nemo.core.classes.common import PretrainedModelInfo, typecheck
  from nemo.core.neural_types import ChannelType, LogitsType, MaskType, NeuralType
  from nemo.utils import logging
label_desc: Use image node_id 8 for calling the DuplexTaggerModel obj's underlying member method code with example usage: obj.validation_step(batch, batch_idx) without return types