class_docstr: Dialogue Nearest Neighbour Model identifies the intent of an utterance using the cosine similarity between sentence embeddings of the utterance and various label descriptions 
class_docstr_tok: ["Dialogue","Nearest","Neighbour","Model","identifies","the","intent","of","an","utterance","using","the","cosine","similarity","between","sentence","embeddings","of","the","utterance","and","various","label","descriptions"]
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, mode="val"):
      """
      Lightning calls this inside the validation loop with the data from the validation dataloader
      passed in as `batch`.
      """
      input_ids, input_mask, labels = batch
      preds = []
      gts = []
      inputs = []
      for i in range(input_ids.size(0)):
          output = self.forward(
              input_ids=input_ids[i], attention_mask=input_mask[i]
          )
          sentence_embeddings = (
              DialogueNearestNeighbourModel.mean_pooling(
                  output, input_mask[i]
              )
          )
          sentence_embeddings = F.normalize(
              sentence_embeddings, p=2, dim=1
          )
          cos_sim = F.cosine_similarity(
              sentence_embeddings[:1, :], sentence_embeddings[1:, :]
          )
          pred = torch.argmax(cos_sim).item() + 1
          gt = torch.argmax(labels[i][1:]).item() + 1
  
          preds.append(input_ids[i, pred])
          gts.append(input_ids[i, gt])
          inputs.append(input_ids[i, 0])
  
      loss = {
          "preds": torch.stack(preds),
          "labels": torch.stack(gts),
          "inputs": torch.stack(inputs),
      }
      self.validation_step_outputs.append(loss)
      return loss
  
imports: import os
  from typing import Optional
  import numpy
  import torch
  import torch.nn.functional
  from omegaconf import DictConfig
  from pytorch_lightning import Trainer
  from transformers import AutoModel
  from nemo.collections.nlp.data.dialogue import DialogueSGDDataProcessor
  from nemo.collections.nlp.data.dialogue.data_processor.assistant_data_processor import DialogueAssistantDataProcessor
  from nemo.collections.nlp.data.dialogue.data_processor.design_data_processor import DialogueDesignDataProcessor
  from nemo.collections.nlp.data.dialogue.dataset.dialogue_nearest_neighbour_dataset import DialogueNearestNeighbourDataset
  from nemo.collections.nlp.metrics.classification_report import ClassificationReport
  from nemo.collections.nlp.metrics.dialogue_metrics import DialogueGenerationMetrics
  from nemo.collections.nlp.models.nlp_model import NLPModel
  from nemo.core.classes.common import PretrainedModelInfo
  from nemo.utils import logging
label_desc: Use image node_id 7 for calling the DialogueNearestNeighbourModel obj's underlying member method code with example usage: obj.validation_step(batch, batch_idx, mode) and returns: loss