class_docstr: This is a classification model that selects the best heteronym option out of possible dictionary entries.
  Supports only heteronyms, no OOV.
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`.
      """
      val_loss, logits = self.make_step(batch)
      subtokens_mask = batch["subtokens_mask"]
      targets = batch["targets"]
      targets = targets[targets != -100]
  
      self.log(f"{split}_loss", val_loss)
      tag_preds = torch.argmax(logits, axis=-1)[subtokens_mask > 0]
      tp, fn, fp, _ = self.classification_report(tag_preds, targets)
      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 json
  import os
  from typing import List, Optional
  import torch
  from hydra.utils import instantiate
  from omegaconf import DictConfig
  from pytorch_lightning import Trainer
  from nemo.collections.common.losses import CrossEntropyLoss
  from nemo.collections.nlp.metrics.classification_report import ClassificationReport
  from nemo.collections.nlp.modules.common import TokenClassifier
  from nemo.collections.nlp.parts.utils_funcs import tensor2list
  from nemo.collections.tts.g2p.data.heteronym_classification import HeteronymClassificationDataset
  from nemo.collections.tts.g2p.utils import get_heteronym_spans, get_wordid_to_phonemes, read_wordids
  from nemo.core.classes.common import PretrainedModelInfo
  from nemo.utils import logging
label_desc: Use image node_id 6 for calling the HeteronymClassificationModel obj's underlying member method code with example usage: obj.validation_step(batch, batch_idx, split) and returns: loss