code: def _flatten_probas(probas, labels, ignore=None):
      """Flattens predictions in the batch"""
      if probas.dim() == 3:
          # assumes output of a sigmoid layer
          B, H, W = probas.size()
          probas = probas.view(B, 1, H, W)
  
      C = probas.size(1)
      probas = torch.movedim(
          probas, 1, -1
      )  # [B, C, Di, Dj, ...] -> [B, Di, Dj, ..., C]
      probas = probas.contiguous().view(-1, C)  # [P, C]
  
      labels = labels.view(-1)
      if ignore is None:
          return probas, labels
      valid = labels != ignore
      vprobas = probas[valid]
      vlabels = labels[valid]
      return vprobas, vlabels
  
imports: from __future__ import print_function, division
  from typing import Optional, Union
  import torch
  import torch.nn.functional
  from torch.autograd import Variable
  from torch.nn.modules.loss import _Loss
label_desc: Use image node_id 7 for calling a global function with example usage: _flatten_probas(probas, labels, ignore) and returns: vprobas,  vlabels, probas,  labels