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)
      B, C, H, W = probas.size()
      probas = (
          probas.permute(0, 2, 3, 1).contiguous().view(-1, C)
      )  # B * H * W, C = P, C
      labels = labels.view(-1)
      if ignore is None:
          return probas, labels
      valid = labels != ignore
      # vprobas = probas[valid.nonzero().squeeze()]
      vprobas = probas[torch.nonzero(valid, as_tuple=False).squeeze()]
      vlabels = labels[valid]
      return vprobas, vlabels
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import numpy
  import torch
  import torch.nn.functional
  from torch import nn
  from torch.autograd import Variable
label_desc: Use image node_id 10 for calling a global function with example usage: flatten_probas(probas, labels, ignore) and returns: vprobas,  vlabels, probas,  labels