code: def forward(self, X, T):
      P = self.proxies
  
      cos = F.linear(
          l2_norm(X), l2_norm(P)
      )  # Calcluate cosine similarity
      P_one_hot = binarize(T=T, nb_classes=self.nb_classes).to(X.device)
      N_one_hot = 1 - P_one_hot
  
      pos_exp = torch.exp(-self.alpha * (cos - self.mrg))
      neg_exp = torch.exp(self.alpha * (cos + self.mrg))
  
      with_pos_proxies = torch.where(P_one_hot.sum(dim=0) != 0)[
          0
      ]  # The set of positive proxies of data in the batch
      num_valid_proxies = len(
          with_pos_proxies
      )  # The number of positive proxies
  
      P_sim_sum = torch.where(
          P_one_hot == 1, pos_exp, torch.zeros_like(pos_exp)
      ).sum(dim=0)
      N_sim_sum = torch.where(
          N_one_hot == 1, neg_exp, torch.zeros_like(neg_exp)
      ).sum(dim=0)
  
      pos_term = torch.log(1 + P_sim_sum).sum() / num_valid_proxies
      neg_term = torch.log(1 + N_sim_sum).sum() / self.nb_classes
      loss = pos_term + neg_term
  
      return loss
  
file_path: pytorch-metric-learning/tests/losses/test_proxy_anchor_loss.py
imports: from contextlib import nullcontext
  import torch
  import torch.nn
  import torch.nn.functional
  import unittest
  import torch
  from pytorch_metric_learning.losses import ProxyAnchorLoss
  from ..None import TEST_DEVICE, TEST_DTYPES
  from ..zzz_testing_utils.testing_utils import angle_to_coord
label_desc: Use image node_id 2 for calling the OriginalImplementationProxyAnchor obj's underlying member method code with example usage: obj.forward(X, T) and returns: loss