code: def mask_to_tensor(mask, num_classes, sigmoid):
      if num_classes > 1:
          if not sigmoid:
              # softmax
              long_mask = np.zeros((mask.shape[:2]), dtype=np.int64)
              if len(mask.shape) == 3:
                  for c in range(mask.shape[2]):
                      long_mask[mask[..., c] > 0] = c
              else:
                  long_mask[mask > 127] = 1
                  long_mask[mask == 0] = 0
              mask = long_mask
          else:
              mask = np.moveaxis(
                  mask / (255.0 if mask.dtype == np.uint8 else 1), -1, 0
              ).astype(np.float32)
      else:
          mask = np.expand_dims(
              mask / (255.0 if mask.dtype == np.uint8 else 1), 0
          ).astype(np.float32)
      return torch.from_numpy(mask)
  
imports: from __future__ import absolute_import
  import warnings
  import numpy
  import torch
  from torchvision.transforms import functional
  from ..core.transforms_interface import BasicTransform
label_desc: Use image node_id 2 for calling a global function with example usage: mask_to_tensor(mask, num_classes, sigmoid) and returns: torch