code: def predict_cases(
      predictor,
      list_of_lists,
      output_filenames,
      save_npz,
      num_threads_preprocessing,
      num_threads_nifti_save,
      segs_from_prev_stage=None,
      do_tta=True,
      mixed_precision=True,
      overwrite_existing=False,
      all_in_gpu=False,
      step_size=0.5,
      disable_postprocessing=False,
      segmentation_export_kwargs: dict = None,
      postprocessing_json_path=None,
  ):
      assert len(list_of_lists) == len(
          output_filenames
      ), "The number of input files and output files is not same. Please check your input folder."
      if segs_from_prev_stage is not None:
          assert len(segs_from_prev_stage) == len(
              output_filenames
          ), "The cascade lowres predict results is not the same with the number of output files."
  
      pool = Pool(num_threads_nifti_save)
      results = []
  
      cleaned_output_files = []
      for o in output_filenames:
          dr, f = os.path.split(o)
          if len(dr) > 0:
              os.makedirs(dr, exist_ok=True)
          if not f.endswith(".nii.gz"):
              f, _ = os.path.splitext(f)
              f = f + ".nii.gz"
          cleaned_output_files.append(os.path.join(dr, f))
  
      if not overwrite_existing:
          print("number of cases:", len(list_of_lists))
          not_done_idx = [
              i
              for i, j in enumerate(cleaned_output_files)
              if (not os.path.isfile(j))
              or (save_npz and not os.path.isfile(j[:-7] + ".npz"))
          ]
  
          cleaned_output_files = [
              cleaned_output_files[i] for i in not_done_idx
          ]
          list_of_lists = [list_of_lists[i] for i in not_done_idx]
          if segs_from_prev_stage is not None:
              segs_from_prev_stage = [
                  segs_from_prev_stage[i] for i in not_done_idx
              ]
  
          print(
              "number of cases that still need to be predicted:",
              len(cleaned_output_files),
          )
  
      if segmentation_export_kwargs is None:
          if "segmentation_export_params" in predictor.plans.keys():
              force_separate_z = predictor.plans[
                  "segmentation_export_params"
              ]["force_separate_z"]
              interpolation_order = predictor.plans[
                  "segmentation_export_params"
              ]["interpolation_order"]
              interpolation_order_z = predictor.plans[
                  "segmentation_export_params"
              ]["interpolation_order_z"]
          else:
              force_separate_z = None
              interpolation_order = 1
              interpolation_order_z = 0
      else:
          force_separate_z = segmentation_export_kwargs[
              "force_separate_z"
          ]
          interpolation_order = segmentation_export_kwargs[
              "interpolation_order"
          ]
          interpolation_order_z = segmentation_export_kwargs[
              "interpolation_order_z"
          ]
  
      print("starting preprocessing generator")
      print("file list: ", list_of_lists)
      print("preprocess output files: ", cleaned_output_files)
      preprocessing = preprocess_multithreaded(
          predictor,
          list_of_lists,
          cleaned_output_files,
          num_threads_preprocessing,
          segs_from_prev_stage,
      )
      print("starting prediction...")
      all_output_files = []
      for preprocessed in preprocessing:
          output_filename, (d, dct) = preprocessed
          all_output_files.append(all_output_files)
          if isinstance(d, str):
              data = np.load(d)
              os.remove(d)
              d = data
  
          print("predicting", output_filename)
          softmax = predictor.multi_folds_predict_preprocessed_data_return_seg_and_softmax(
              data=d,
              do_mirroring=do_tta,
              mirror_axes=predictor.data_aug_params["mirror_axes"],
              use_sliding_window=True,
              step_size=step_size,
              use_gaussian=True,
              mixed_precision=mixed_precision,
          )
  
          transpose_forward = predictor.plans.get("transpose_forward")
          if transpose_forward is not None:
              transpose_backward = predictor.plans.get(
                  "transpose_backward"
              )
              softmax = softmax.transpose(
                  [0] + [i + 1 for i in transpose_backward]
              )
  
          if save_npz:
              npz_file = output_filename[:-7] + ".npz"
          else:
              npz_file = None
  
          if hasattr(predictor, "regions_class_order"):
              region_class_order = predictor.regions_class_order
          else:
              region_class_order = None
  
          bytes_per_voxel = 4
          if all_in_gpu:
              bytes_per_voxel = 2
          if np.prod(softmax.shape) > (2e9 / bytes_per_voxel * 0.85):
              print(
                  "This output is too large for python process-process communication. Saving output temporarily to disk"
              )
              np.save(output_filename[:-7] + ".npy", softmax)
              softmax = output_filename[:-7] + ".npy"
  
          results.append(
              pool.starmap_async(
                  save_segmentation_nifti_from_softmax,
                  (
                      (
                          softmax,
                          output_filename,
                          dct,
                          interpolation_order,
                          region_class_order,
                          None,
                          None,
                          npz_file,
                          None,
                          force_separate_z,
                          interpolation_order_z,
                      ),
                  ),
              )
          )
  
      print(
          "inference done. Now waiting for the segmentation export to finish..."
      )
      _ = [i.get() for i in results]
  
      if not disable_postprocessing:
          results = []
          pp_file = postprocessing_json_path
          if os.path.isfile(pp_file):
              print("postprocessing...")
              shutil.copy(
                  pp_file,
                  os.path.abspath(os.path.dirname(output_filenames[0])),
              )
              (
                  for_which_classes,
                  min_valid_obj_size,
              ) = load_postprocessing(pp_file)
              results.append(
                  pool.starmap_async(
                      load_remove_save,
                      zip(
                          output_filenames,
                          output_filenames,
                          [for_which_classes] * len(output_filenames),
                          [min_valid_obj_size] * len(output_filenames),
                      ),
                  )
              )
              _ = [i.get() for i in results]
          else:
              print(
                  "WARNING! Cannot run postprocessing because the postprocessing file is missing. Make sure to run "
                  "consolidate_folds in the output folder of the model first!"
              )
  
      pool.close()
      pool.join()
  
file_path: PaddleSeg/contrib/MedicalSeg/nnunet/utils/predict_utils.py
imports: import os
  import sys
  import ast
  import shutil
  import json
  import pickle
  import numpy
  from copy import deepcopy
  from typing import Tuple, Union
  import SimpleITK
  from multiprocessing import Process, Queue, Pool
  from nnunet.utils import load_remove_save
  from nnunet.transforms import resize_segmentation
  from .utils import save_segmentation_nifti_from_softmax
  from tools.preprocess_utils import get_do_separate_z, get_lowres_axis, resample_data_or_seg
label_desc: Use image node_id 5 for calling a global function with example usage: predict_cases(predictor, list_of_lists, output_filenames, save_npz, num_threads_preprocessing, num_threads_nifti_save, segs_from_prev_stage, do_tta, mixed_precision, overwrite_existing, all_in_gpu, step_size, disable_postprocessing, segmentation_export_kwargs, postprocessing_json_path) without return types