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
class_docstr_tok: ["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 training step. This function is registered by LightningModule.
  Refer to https://lightning.ai/docs/pytorch/stable/common/lightning_module.html#training-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 training loss.
  batch_idx
      Index of mini-batch.
  
  Returns
  -------
  Average loss of the mini-batch data.
docstr_tok: ["Per","training","step",".","This","function","is","registered","by","LightningModule",".","Refer","to","https",":","\/\/lightning.ai\/docs\/pytorch\/stable\/common\/lightning_module.html","#","training-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","training","loss",".","batch_idx","Index","of","mini-batch",".","Returns","--","--","--","-","Average","loss","of","the","mini-batch","data","."]
code: def training_step(self, batch, batch_idx):
      """
      Per training step. This function is registered by LightningModule.
      Refer to https://lightning.ai/docs/pytorch/stable/common/lightning_module.html#training-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 training loss.
      batch_idx
          Index of mini-batch.
  
      Returns
      -------
      Average loss of the mini-batch data.
      """
      _, _, _, loss = self._shared_step(batch)
      self.log("train_loss", loss)
      return loss
  
imports: import logging
  from typing import Callable, Dict, List, Optional, Union
  import lightning.pytorch
  import torch
  import torchmetrics
  from lightning.pytorch.utilities import grad_norm
  from omegaconf import DictConfig
  from torch import nn
  from torch.nn.modules.loss import _Loss
  from torchmetrics.aggregation import BaseAggregator
  from ..constants import FEATURES, LOGIT_SCALE, PROBABILITY, QUERY, RESPONSE
  from ..models.utils import run_model
  from ..utils.matcher import compute_matching_probability
  from .losses import MultiNegativesSoftmaxLoss
  from .utils import CustomHitRate, apply_layerwise_lr_decay, apply_single_lr, apply_two_stages_lr, generate_metric_learning_labels, get_lr_scheduler, get_optimizer
label_desc: Use image node_id 6 for calling the MatcherLitModule obj's underlying member method code with example usage: obj.training_step(batch, batch_idx) and returns: loss