code: def flatten_probas(input, target, labels, ignore=255):
      """
      Flattens predictions in the batch.
      """
      B, C, H, W = input.size()
      input = (
          input.permute(0, 2, 3, 1).contiguous().view(-1, C)
      )  # B * H * W, C = P, C
      target = (
          target.permute(0, 2, 3, 1).contiguous().view(-1, C)
      )  # B * H * W, C = P, C
      labels = labels.view(-1)
      if ignore is None:
          return input, target
      valid = labels != ignore
      vinput = input[torch.nonzero(valid, as_tuple=False).squeeze()]
      vtarget = target[torch.nonzero(valid, as_tuple=False).squeeze()]
      return vinput, vtarget
  
file_path: insightface/parsing/dml_csr/loss/kl_loss.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import torch
  import torch.nn.functional
  from torch import nn
label_desc: Use image node_id 1 for calling a global function with example usage: flatten_probas(input, target, labels, ignore) and returns: vinput,  vtarget, input,  target