def METHOD_NAME(self, dvecs):
    """Calculate cosine similarity matrix of shape (N, M, N)."""
    n_spkr, n_uttr, d_embd = dvecs.size()
    dvec_expns = dvecs.unsqueeze(-1).expand(n_spkr, n_uttr, d_embd, n_spkr)
    dvec_expns = dvec_expns.transpose(2, 3)
    ctrds = dvecs.mean(dim=1).to(dvecs.device)
    ctrd_expns = ctrds.unsqueeze(0).expand(n_spkr * n_uttr, n_spkr, d_embd)
    ctrd_expns = ctrd_expns.reshape(-1, d_embd)
    dvec_rolls = torch.cat([dvecs[:, 1:, :], dvecs[:, :-1, :]], dim=1)
    dvec_excls = dvec_rolls.unfold(1, n_uttr-1, 1)
    mean_excls = dvec_excls.mean(dim=-1).reshape(-1, d_embd)
    indices = _indices_to_replace(n_spkr, n_uttr).to(dvecs.device)
    ctrd_excls = ctrd_expns.index_copy(0, indices, mean_excls)
    ctrd_excls = ctrd_excls.view_as(dvec_expns)
    return F.METHOD_NAME(dvec_expns, ctrd_excls, 3, 1e-9)