class_docstr: Control the loops for training, evaluation, and prediction. This module is independent of
  the model definition. This class inherits from the Pytorch Lightning's LightningModule:
  https://lightning.ai/docs/pytorch/stable/common/lightning_module.html
docstr: Per validation step. This function is registered by LightningModule.
  Refer to https://lightning.ai/docs/pytorch/stable/common/lightning_module.html#validation-loop
  
  Parameters
  ----------
  batch
      A dictionary containing the mini-batch data, including both input data and
      ground-truth labels. The mini-batch data are passed to each individual model,
      which indexes its required input data by keys with its model prefix. The
      ground-truth labels are used here to compute the validation loss and metric.
      The validation metric is used for top k model selection and early stopping.
  batch_idx
      Index of mini-batch.
docstr_tok: ["Per","validation","step",".","This","function","is","registered","by","LightningModule",".","Refer","to","https",":","\/\/lightning.ai\/docs\/pytorch\/stable\/common\/lightning_module.html","#","validation-loop","Parameters","--","--","--","--","--","batch","A","dictionary","containing","the","mini-batch","data",",","including","both","input","data","and","ground-truth","labels",".","The","mini-batch","data","are","passed","to","each","individual","model",",","which","indexes","its","required","input","data","by","keys","with","its","model","prefix",".","The","ground-truth","labels","are","used","here","to","compute","the","validation","loss","and","metric",".","The","validation","metric","is","used","for","top","k","model","selection","and","early","stopping",".","batch_idx","Index","of","mini-batch","."]
code: def validation_step(self, batch, batch_idx):
      """
      Per validation step. This function is registered by LightningModule.
      Refer to https://lightning.ai/docs/pytorch/stable/common/lightning_module.html#validation-loop
  
      Parameters
      ----------
      batch
          A dictionary containing the mini-batch data, including both input data and
          ground-truth labels. The mini-batch data are passed to each individual model,
          which indexes its required input data by keys with its model prefix. The
          ground-truth labels are used here to compute the validation loss and metric.
          The validation metric is used for top k model selection and early stopping.
      batch_idx
          Index of mini-batch.
      """
      output, loss = self._shared_step(batch)
      if self.model_postprocess_fn:
          output = self.model_postprocess_fn(output)
      # By default, on_step=False and on_epoch=True
      self.log("val_loss", loss)
      self._compute_metric_score(
          metric=self.validation_metric,
          custom_metric_func=self.custom_metric_func,
          logits=output[self.model.prefix][LOGITS],
          label=batch[self.model.label_key],
      ),
      self.log(
          self.validation_metric_name,
          self.validation_metric,
          on_step=False,
          on_epoch=True,
      )
  
imports: import logging
  from typing import Callable, Dict, List, Optional, Union
  import lightning.pytorch
  import torch
  import torch.nn.functional
  import torchmetrics
  from lightning.pytorch.strategies import DeepSpeedStrategy
  from lightning.pytorch.utilities import grad_norm
  from torch import nn
  from torch.nn.modules.loss import _Loss
  from torchmetrics.aggregation import BaseAggregator
  from ..constants import LM_TARGET, LOGITS, T_FEW, TEMPLATE_LOGITS, WEIGHT
  from ..data.mixup import MixupModule, multimodel_mixup
  from ..models.utils import run_model
  from .semantic_seg_metrics import COD, Balanced_Error_Rate
  from .utils import apply_layerwise_lr_decay, apply_single_lr, apply_two_stages_lr, get_lr_scheduler, get_optimizer
label_desc: Use image node_id 8 for calling the LitModule obj's underlying member method code with example usage: obj.validation_step(batch, batch_idx) without return types