code: def to_one_hot(seg, all_seg_labels=None):
      if all_seg_labels is None:
          all_seg_labels = np.unique(seg)
      result = np.zeros(
          (len(all_seg_labels), *seg.shape), dtype=seg.dtype
      )
      for i, l in enumerate(all_seg_labels):
          result[i][seg == l] = 1
      return result
  
file_path: PaddleSeg/contrib/MedicalSeg/nnunet/single_fold_eval.py
imports: import argparse
  import os
  import shutil
  import paddle
  import numpy
  import pickle
  import sys
  from medicalseg.cvlibs import Config
  from medicalseg.utils import get_sys_env, logger, config_check, utils
  from nnunet.utils import DynamicPredictor, save_segmentation_nifti_from_softmax, aggregate_scores, determine_postprocessing, resample_and_save, predict_next_stage
label_desc: Use image node_id 1 for calling a global function with example usage: to_one_hot(seg, all_seg_labels) and returns: result