code: def nca_computation(
      self,
      query,
      reference,
      query_labels,
      reference_labels,
      indices_tuple,
  ):
      dtype = query.dtype
      miner_weights = lmu.convert_to_weights(
          indices_tuple,
          query_labels,
          dtype=dtype,
          using_ref=query is not reference,
      )
      mat = self.distance(query, reference)
      if not self.distance.is_inverted:
          mat = -mat
      if query is reference:
          mat.fill_diagonal_(c_f.neg_inf(dtype))
      same_labels = c_f.to_dtype(
          query_labels.unsqueeze(1) == reference_labels.unsqueeze(0),
          dtype=dtype,
      )
      exp = torch.nn.functional.softmax(self.softmax_scale * mat, dim=1)
      exp = torch.sum(exp * same_labels, dim=1)
      non_zero = exp != 0
      loss = -torch.log(exp[non_zero]) * miner_weights[non_zero]
      return {
          "loss": {
              "losses": loss,
              "indices": c_f.torch_arange_from_size(query)[non_zero],
              "reduction_type": "element",
          }
      }
  
file_path: pytorch-metric-learning/src/pytorch_metric_learning/losses/nca_loss.py
imports: import torch
  from ..distances import LpDistance
  from ..utils import common_functions
  from ..utils import loss_and_miner_utils
  from .base_metric_loss_function import BaseMetricLossFunction
label_desc: Use image node_id 3 for calling the NCALoss obj's underlying member method code with example usage: obj.nca_computation(query, reference, query_labels, reference_labels, indices_tuple) and returns: dict