code: def binary_cross_entropy(
      pred,
      label,
      weight=None,
      reduction="mean",
      avg_factor=None,
      class_weight=None,
      ignore_index=255,
  ):
      """Calculate the binary CrossEntropy loss.
  
      Args:
          pred (torch.Tensor): The prediction with shape (N, 1).
          label (torch.Tensor): The learning label of the prediction.
          weight (torch.Tensor, optional): Sample-wise loss weight.
          reduction (str, optional): The method used to reduce the loss.
              Options are "none", "mean" and "sum".
          avg_factor (int, optional): Average factor that is used to average
              the loss. Defaults to None.
          class_weight (list[float], optional): The weight for each class.
          ignore_index (int | None): The label index to be ignored. Default: 255
  
      Returns:
          torch.Tensor: The calculated loss
      """
      if pred.dim() != label.dim():
          assert (pred.dim() == 2 and label.dim() == 1) or (
              pred.dim() == 4 and label.dim() == 3
          ), (
              "Only pred shape [N, C], label shape [N] or pred shape [N, C, "
              "H, W], label shape [N, H, W] are supported"
          )
          label, weight = _expand_onehot_labels(
              label, weight, pred.shape, ignore_index
          )
  
      # weighted element-wise losses
      if weight is not None:
          weight = weight.float()
      loss = F.binary_cross_entropy_with_logits(
          pred, label.float(), pos_weight=class_weight, reduction="none"
      )
      # do the reduction for the weighted loss
      loss = weight_reduce_loss(
          loss, weight, reduction=reduction, avg_factor=avg_factor
      )
  
      return loss
  
file_path: lavis/lavis/common/annotator/uniformer/mmseg/models/losses/cross_entropy_loss.py
imports: import torch
  import torch.nn
  import torch.nn.functional
  from ..builder import LOSSES
  from .utils import get_class_weight, weight_reduce_loss
label_desc: Use image node_id 3 for calling a global function with example usage: binary_cross_entropy(pred, label, weight, reduction, avg_factor, class_weight, ignore_index) and returns: loss