code: def merge_files(
      files, properties_files, out_file, override=False, store_npz=False
  ):
      if override or not os.path.exists(out_file):
          print("ensemble files: ", files)
          softmax = [np.load(file)["softmax"][None] for file in files]
          softmax = np.vstack(softmax)
          softmax = np.mean(softmax, 0)
          props = [load_pickle(f) for f in properties_files]
          reg_class_orders = [
              p["regions_class_order"]
              if "regions_class_order" in p.keys()
              else None
              for p in props
          ]
          if not all([i is None for i in reg_class_orders]):
              tmp = reg_class_orders[0]
              for r in reg_class_orders[1:]:
                  assert (
                      tmp == r
                  ), "If merging files with regions_class_order, the regions_class_orders of all files must be the same. regions_class_order: {}, \n files: {}.".format(
                      str(reg_class_orders), str(files)
                  )
              regions_class_order = tmp
          else:
              regions_class_order = None
          save_segmentation_nifti_from_softmax(
              softmax,
              out_file,
              props[0],
              3,
              regions_class_order,
              None,
              None,
              force_separate_z=None,
          )
          if store_npz:
              np.savez_compressed(
                  out_file[:-7] + ".npz", softmax=softmax
              )
              with open(out_file[:-7] + ".pkl", "wb") as f:
                  pickle.dump(props, f)
      else:
          print("{} already exists. Skip.".format(out_file))
  
file_path: PaddleSeg/contrib/MedicalSeg/nnunet/ensemble.py
imports: import argparse
  import os
  import sys
  import ast
  import json
  import numpy
  import pickle
  import shutil
  from copy import deepcopy
  from multiprocessing import Pool
  from itertools import combinations
  from nnunet.utils import save_segmentation_nifti_from_softmax, load_remove_save, aggregate_scores, determine_postprocessing
label_desc: Use image node_id 3 for calling a global function with example usage: merge_files(files, properties_files, out_file, override, store_npz) without return types