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, split="val"):
      """
      Lightning calls this inside the validation loop with the data from the validation dataloader
      passed in as `batch`.
      """
      input_ids, input_type_ids, input_mask, labels = batch
      logits = self.forward(
          input_ids=input_ids,
          token_type_ids=input_type_ids,
          attention_mask=input_mask,
      )
  
      val_loss = self.loss(logits=logits, labels=labels)
  
      preds = torch.argmax(logits, axis=-1)
  
      tp, fn, fp, _ = self.classification_report(preds, labels)
  
      loss = {f"{split}_loss": val_loss, "tp": tp, "fn": fn, "fp": fp}
      if split == "val":
          self.validation_step_outputs.append(loss)
      elif split == "test":
          self.test_step_outputs.append(loss)
      return loss
  
imports: import os
  from typing import Dict, List, Optional
  import torch
  from omegaconf import DictConfig
  from pytorch_lightning import Trainer
  from nemo.collections.common.losses import CrossEntropyLoss
  from nemo.collections.nlp.data.text_classification import TextClassificationDataset, calc_class_weights
  from nemo.collections.nlp.metrics.classification_report import ClassificationReport
  from nemo.collections.nlp.models.nlp_model import NLPModel
  from nemo.collections.nlp.modules.common import SequenceClassifier
  from nemo.collections.nlp.parts.utils_funcs import tensor2list
  from nemo.core.classes.common import typecheck
  from nemo.core.classes.exportable import Exportable
  from nemo.utils import logging
label_desc: Use image node_id 5 for calling the TextClassificationModel obj's underlying member method code with example usage: obj.validation_step(batch, batch_idx, split) and returns: loss