code: def flatten_probas(probas, labels, ignore=None):
      """
      Flattens predictions in the batch.
      """
      if len(probas.shape) == 3:
          probas = paddle.unsqueeze(probas, axis=1)
      C = probas.shape[1]
      probas = paddle.transpose(probas, [0, 2, 3, 1])
      probas = paddle.reshape(probas, [-1, C])
      labels = paddle.reshape(labels, [-1])
      if ignore is None:
          return probas, labels
      valid = labels != ignore
      valid_mask = paddle.reshape(valid, [-1, 1])
      indexs = paddle.nonzero(valid_mask)
      indexs.stop_gradient = True
      vprobas = paddle.gather(probas, indexs[:, 0])
      vlabels = paddle.gather(labels, indexs[:, 0])
      return vprobas, vlabels
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import numpy
  import paddle
  from paddle import nn
  import paddle.nn.functional
  from paddleseg.cvlibs import manager
label_desc: Use image node_id 6 for calling a global function with example usage: flatten_probas(probas, labels, ignore) and returns: vprobas,  vlabels, probas,  labels