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"]
code: def _shared_step(
      self,
      batch: Dict,
  ):
      query_outputs = run_model(self.query_model, batch)[
          self.query_model.prefix
      ]
      query_embeddings = query_outputs[FEATURES]
  
      response_outputs = run_model(self.response_model, batch)[
          self.response_model.prefix
      ]
      response_embeddings = response_outputs[FEATURES]
  
      logit_scale = (
          response_outputs[LOGIT_SCALE]
          if LOGIT_SCALE in response_outputs
          else None,
      )
  
      if isinstance(logit_scale, tuple):
          logit_scale = logit_scale[0]
  
      loss = self._compute_loss(
          query_embeddings=query_embeddings,
          response_embeddings=response_embeddings,
          label=self._get_label(batch),
          logit_scale=logit_scale,
      )
      return query_embeddings, response_embeddings, logit_scale, 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 5 for calling the MatcherLitModule obj's underlying member method code with example usage: obj._shared_step(batch) and returns: query_embeddings,  response_embeddings,  logit_scale,  loss