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 _compute_loss(
      self,
      query_embeddings: torch.Tensor,
      response_embeddings: torch.Tensor,
      label: torch.Tensor,
      logit_scale: Optional[torch.tensor] = None,
  ):
      assert query_embeddings.shape == response_embeddings.shape
  
      if isinstance(self.loss_func, MultiNegativesSoftmaxLoss):
          loss = self.loss_func(
              features_a=query_embeddings,
              features_b=response_embeddings,
              logit_scale=logit_scale,
              rank=self.global_rank,
              world_size=self.trainer.world_size,
          )
      else:
          embeddings = torch.cat(
              [query_embeddings, response_embeddings], dim=0
          )  # (b*2, d)
  
          metric_learning_labels = generate_metric_learning_labels(
              num_samples=len(query_embeddings),
              match_label=self.match_label,
              labels=label,
          )
          indices_tuple = self.miner_func(
              embeddings=embeddings,
              labels=metric_learning_labels,
          )
          loss = self.loss_func(
              embeddings=embeddings,
              labels=metric_learning_labels,
              indices_tuple=indices_tuple,
          )
  
      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 2 for calling the MatcherLitModule obj's underlying member method code with example usage: obj._compute_loss(query_embeddings, response_embeddings, label, logit_scale) and returns: loss