code: def build_target(
      target: torch.Tensor,
      num_classes: int = 2,
      ignore_index: int = -100,
  ):
      """build target for dice coefficient"""
      dice_target = target.clone()
      if ignore_index >= 0:
          ignore_mask = torch.eq(target, ignore_index)
          dice_target[ignore_mask] = 0
          # [N, H, W] -> [N, H, W, C]
          dice_target = nn.functional.one_hot(
              dice_target, num_classes
          ).float()
          dice_target[ignore_mask] = ignore_index
      else:
          dice_target = nn.functional.one_hot(
              dice_target, num_classes
          ).float()
  
      return dice_target.permute(0, 3, 1, 2)
  
imports: import torch
  import torch.nn
label_desc: Use image node_id 1 for calling a global function with example usage: build_target(target, num_classes, ignore_index) and returns: dice_target