code: def flatten_binary_logits(logits, labels, ignore_index=None):
      """Flattens predictions in the batch (binary case) Remove labels equal to
      'ignore_index'."""
      logits = logits.view(-1)
      labels = labels.view(-1)
      if ignore_index is None:
          return logits, labels
      valid = labels != ignore_index
      vlogits = logits[valid]
      vlabels = labels[valid]
      return vlogits, vlabels
  
file_path: lavis/lavis/common/annotator/uniformer/mmseg/models/losses/lovasz_loss.py
imports: import annotator.uniformer.mmcv
  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 2 for calling a global function with example usage: flatten_binary_logits(logits, labels, ignore_index) and returns: vlogits,  vlabels, logits,  labels