class_docstr: BERT language model pretraining.
class_docstr_tok: ["BERT","language","model","pretraining","."]
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`.
      """
      (
          input_ids,
          input_type_ids,
          input_mask,
          output_ids,
          output_mask,
          labels,
      ) = batch
      forward_outputs = self.forward(
          input_ids=input_ids,
          token_type_ids=input_type_ids,
          attention_mask=input_mask,
      )
      mlm_log_probs, nsp_logits = self._parse_forward_outputs(
          forward_outputs
      )
      _, _, loss = self._compute_losses(
          mlm_log_probs, nsp_logits, output_ids, output_mask, labels
      )
      self.validation_perplexity(logits=mlm_log_probs)
      loss = {"val_loss": loss}
      self.validation_step_outputs.append(loss)
      return loss
  
imports: import os
  from typing import Dict, Optional
  import torch
  from omegaconf import DictConfig, OmegaConf
  from pytorch_lightning import Trainer
  from torch.utils.data import DataLoader
  from nemo.collections.common.losses import AggregatorLoss, CrossEntropyLoss, SmoothedCrossEntropyLoss
  from nemo.collections.common.metrics import Perplexity
  from nemo.collections.nlp.data.language_modeling.lm_bert_dataset import BertPretrainingDataset, BertPretrainingPreprocessedDataloader
  from nemo.collections.nlp.modules.common import BertPretrainingTokenClassifier, SequenceClassifier
  from nemo.collections.nlp.modules.common.lm_utils import get_lm_model
  from nemo.collections.nlp.modules.common.tokenizer_utils import get_tokenizer
  from nemo.core.classes.common import PretrainedModelInfo, typecheck
  from nemo.core.classes.modelPT import ModelPT
  from nemo.core.neural_types import NeuralType
  from nemo.utils import logging
label_desc: Use image node_id 8 for calling the BERTLMModel obj's underlying member method code with example usage: obj.validation_step(batch, batch_idx) and returns: loss