class_docstr: Pseudo-Prototypical Proxy loss (PPP-loss).
  This is a contrastive loss using prototypes and representations of the
  samples in the batch to optimize the embedding space.
class_docstr_tok: ["Pseudo-Prototypical","Proxy","loss","(","PPP-loss",")",".","This","is","a","contrastive","loss","using","prototypes","and","representations","of","the","samples","in","the","batch","to","optimize","the","embedding","space","."]
docstr: Get the repellor loss terms for all pseudo-prototype instances in Bc.
  :param pc: Actual prototype of the same class c.
  :param pk: Prototoypes of the other classes (k).
  :param Bc: Batch of instances of the same class c. Acting as
  pseudo-prototypes.
  :param Bk: Batch of instances of other-than-c classes (k).
  :return: Sum_{i, part of same class c} Sum_{x_j^k} log 1 - P(c|x_j^k)
docstr_tok: ["Get","the","repellor","loss","terms","for","all","pseudo-prototype","instances","in","Bc",".",":","param","pc",":","Actual","prototype","of","the","same","class","c.",":","param","pk",":","Prototoypes","of","the","other","classes","(","k",")",".",":","param","Bc",":","Batch","of","instances","of","the","same","class","c.","Acting","as","pseudo-prototypes",".",":","param","Bk",":","Batch","of","instances","of","other-than-c","classes","(","k",")",".",":","return",":","Sum_","{","i",",","part","of","same","class","c","}","Sum_","{","x_j^k","}","log","1","-","P","(","c|x_j^k",")"]
code: def repellor(self, pc, pk, Bc, Bk):
      """
      Get the repellor loss terms for all pseudo-prototype instances in Bc.
      :param pc: Actual prototype of the same class c.
      :param pk: Prototoypes of the other classes (k).
      :param Bc: Batch of instances of the same class c. Acting as
      pseudo-prototypes.
      :param Bk: Batch of instances of other-than-c classes (k).
      :return: Sum_{i, part of same class c} Sum_{x_j^k} log 1 - P(c|x_j^k)
      """
      union_ck = torch.cat([Bc.clone(), pc, pk]).detach()
      pk_idx = union_ck.shape[0] - pk.shape[0]
  
      # Distance other-class-k to prototypes (pc/pk) and pseudo-prototype (xc)
      D = torch.mm(union_ck, Bk.t()).div_(self.T).exp_()
  
      Lk_d = (
          D[pk_idx:].sum(dim=0).unsqueeze(0)
      )  # Numerator/denominator terms
      Lc_n = D[:pk_idx]
      Pki = Lc_n / (Lc_n + Lk_d)  # probability
  
      E_Pk = (
          Pki[:-1] + Pki[-1].unsqueeze(0)
      ) / 2  # Exp. pseudo/prototype
      inv_E_Pk = E_Pk.mul_(-1).add_(1).log_()  # log( (1 - Pk))
      return inv_E_Pk.sum()
  
imports: from typing import Dict
  import torch
  from torch import Tensor
  from torch.nn.functional import normalize
  from torch.nn.modules import Module
  from avalanche.training.utils import get_last_fc_layer, swap_last_fc_layer
  from avalanche.training.plugins.strategy_plugin import SupervisedPlugin
  from avalanche.training.storage_policy import ClassBalancedBuffer
  from avalanche.benchmarks.utils.data_loader import ReplayDataLoader
label_desc: Use image node_id 4 for calling the PPPloss obj's underlying member method code with example usage: obj.repellor(pc, pk, Bc, Bk) and returns: inv_E_Pk