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_metric_score(
      metric: torchmetrics.Metric,
      custom_metric_func: Callable,
      label: torch.Tensor,
      query_embeddings: torch.Tensor,
      response_embeddings: torch.Tensor,
      logit_scale: Optional[torch.Tensor] = None,
      reverse_prob: Optional[bool] = False,
  ):
      if isinstance(metric, BaseAggregator):
          metric.update(
              custom_metric_func(
                  query_embeddings, response_embeddings, label
              )
          )
      elif isinstance(metric, CustomHitRate):
          metric.update(
              batch_query_embeds=query_embeddings.cpu(),
              batch_response_embeds=response_embeddings.cpu(),
              logit_scale=logit_scale.cpu() if logit_scale else None,
          )
      else:
          metric.update(
              compute_matching_probability(
                  embeddings1=query_embeddings,
                  embeddings2=response_embeddings,
                  reverse_prob=reverse_prob,
              ),
              label,
          )
  
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 3 for calling the MatcherLitModule obj's underlying member method code with example usage: obj._compute_metric_score(metric, custom_metric_func, label, query_embeddings, response_embeddings, logit_scale, reverse_prob) without return types