def METHOD_NAME(self, batch):
    dtype, device = batch.dtype, batch.device
    self.mask = self.mask.type(dtype).to(device)
    # compute the relevance scores via cosine similarity of the CNN-produced embedding vectors
    sim_all = self.compute_aff(batch)
    sim_all_repeat = sim_all.unsqueeze(dim=1).repeat(1, self.batch_size, 1)
    # compute the difference matrix
    sim_diff = sim_all_repeat - sim_all_repeat.permute(0, 2, 1)
    # pass through the sigmoid and ignores the relevance score of the query to itself
    sim_sg = self.sigmoid(sim_diff, temp=self.anneal) * self.mask
    # compute the rankings,all batch
    sim_all_rk = torch.sum(sim_sg, dim=-1)
    if self.variant == "PNP-D_s":
        sim_all_rk = torch.log(1 + sim_all_rk)
    elif self.variant == "PNP-D_q":
        sim_all_rk = 1 / (1 + sim_all_rk) ** (self.alpha)
    elif self.variant == "PNP-I_u":
        sim_all_rk = (1 + sim_all_rk) * torch.log(1 + sim_all_rk)
    elif self.variant == "PNP-I_b":
        b = self.b
        sim_all_rk = 1 / b**2 * (b * sim_all_rk - torch.log(1 + b * sim_all_rk))
    elif self.variant == "PNP-O":
        pass
    else:
        raise Exception("variantation <{}> not available!".format(self.variant))
    # sum the values of the Smooth-AP for all instances in the mini-batch
    loss = torch.zeros(1).type(dtype).to(device)
    group = int(self.batch_size / self.num_id)
    for ind in range(self.num_id):
        neg_divide = torch.sum(
            sim_all_rk[
                (ind * group) : ((ind + 1) * group),
                (ind * group) : ((ind + 1) * group),
            ]
            / group
        )
        loss = loss + (neg_divide / self.batch_size)
    if self.variant == "PNP-D_q":
        return 1 - loss
    else:
        return loss