code: def to_one_hot(tensor, num_cls, dim=1, ignore_index=255):
      b, h, w = tensor.shape
      tensor[tensor == ignore_index] = 0
      onehot_tensor = torch.zeros(b, num_cls, h, w).cuda()
      onehot_tensor.scatter_(dim, tensor.unsqueeze(dim), 1)
      return onehot_tensor
  
file_path: insightface/parsing/dml_csr/loss/criterion.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import torch.nn
  import torch
  import numpy
  from torch.nn import functional
  from torch.nn.modules.loss import _Loss
  from .lovasz_softmax import LovaszSoftmax
  from .kl_loss import KLDivergenceLoss
  from .consistency_loss import ConsistencyLoss
label_desc: Use image node_id 2 for calling a global function with example usage: to_one_hot(tensor, num_cls, dim, ignore_index) and returns: onehot_tensor