def METHOD_NAME(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