code: def multilabel_categorical_crossentropy(y_pred, y_true):
      y_pred = (1 - 2 * y_true) * y_pred
      y_pred_neg = y_pred - y_true * 1e12
      y_pred_pos = y_pred - (1 - y_true) * 1e12
      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, dim=-1)
      pos_loss = torch.logsumexp(y_pred_pos, dim=-1)
      return (neg_loss + pos_loss).mean()
  
imports: import json
  import torch
  import torch.nn
  import torch.nn.functional
  import numpy
  from .base import BaseLitModel
  from .util import dialog_f1_eval, f1_eval, compute_f1, acc, f1_score
  from transformers.optimization import get_linear_schedule_with_warmup
  from functools import partial
label_desc: Use image node_id 2 for calling a global function with example usage: multilabel_categorical_crossentropy(y_pred, y_true) and returns: unknown