code: def multilabel_categorical_crossentropy(y_true, y_pred):
      """多标签分类的交叉熵
      说明：y_true和y_pred的shape一致，y_true的元素非0即1，
           1表示对应的类为目标类，0表示对应的类为非目标类。
      警告：请保证y_pred的值域是全体实数，换言之一般情况下y_pred
           不用加激活函数，尤其是不能加sigmoid或者softmax！预测
           阶段则输出y_pred大于0的类。如有疑问，请仔细阅读并理解
           本文。
      """
      y_pred = (1 - 2 * y_true) * y_pred
      y_pred_neg = y_pred - y_true * 1e30
      y_pred_pos = y_pred - (1 - y_true) * 1e30
      zeros = torch.zeros_like(y_pred[..., :1])
      y_pred_neg = torch.cat([y_pred_neg, zeros], dim=-1)
      y_pred_pos = torch.cat((y_pred_pos, zeros), dim=-1)
      neg_loss = torch.logsumexp(y_pred_neg, axis=-1)
      pos_loss = torch.logsumexp(y_pred_pos, axis=-1)
      return neg_loss + pos_loss
  
file_path: DeepKE/src/deepke/relation_extraction/document/losses.py
imports: import torch
  import torch.nn
  import torch.nn.functional
label_desc: Use image node_id 1 for calling a global function with example usage: multilabel_categorical_crossentropy(y_true, y_pred) and returns: unknown