class_docstr: Static predictor for nnunet.
class_docstr_tok: ["Static","predictor","for","nnunet","."]
docstr: x: Input data. Must be a nd.ndarray of shape (c, x, y, z).
  do_mirroring: If True, use test time data augmentation in the form of mirroring.
  mirror_axes: Determines which axes to use for mirroing. Per default, mirroring is done along all three axes. Default: (0, 1, 2).
  use_sliding_window: if True, run sliding window prediction. Heavily recommended! Default: True.
  step_size: When running sliding window prediction, the step size determines the distance between adjacent
  predictions. The smaller the step size, the denser the predictions (and the longer it takes!). Step size is given
  as a fraction of the patch_size. 0.5 is the default and means that wen advance by patch_size * 0.5 between
  predictions. step_size cannot be larger than 1! Default: 0.5.
  patch_size: The patch size that was used for training the network. Do not use different patch sizes here,
  this will either crash or give potentially less accurate segmentations. Default: None.
  regions_class_order: Return region class by given order. Default: None.
  use_gaussian: (Only applies to sliding window prediction) If True, uses a Gaussian importance weighting
   to weigh predictions closer to the center of the current patch higher than those at the borders. The reason
   behind this is that the segmentation accuracy decreases towards the borders. Default (and recommended): True
  pad_border_mode: The type of padding image border. Default: 'constant'.
  pad_kwargs: Parameters for padding image border. Default: NOne.
  verbose: Whether print log. Default: True.
  mixed_precision: Whether use amp in inference. Default: True.
docstr_tok: ["x",":","Input","data",".","Must","be","a","nd.ndarray","of","shape","(","c",",","x",",","y",",","z",")",".","do_mirroring",":","If","True",",","use","test","time","data","augmentation","in","the","form","of","mirroring",".","mirror_axes",":","Determines","which","axes","to","use","for","mirroing",".","Per","default",",","mirroring","is","done","along","all","three","axes",".","Default",":","(","0",",","1",",","2",")",".","use_sliding_window",":","if","True",",","run","sliding","window","prediction",".","Heavily","recommended","!","Default",":","True",".","step_size",":","When","running","sliding","window","prediction",",","the","step","size","determines","the","distance","between","adjacent","predictions",".","The","smaller","the","step","size",",","the","denser","the","predictions","(","and","the","longer","it","takes","!",")",".","Step","size","is","given","as","a","fraction","of","the","patch_size",".","0.5","is","the","default","and","means","that","wen","advance","by","patch_size","*","0.5","between","predictions",".","step_size","can","not","be","larger","than","1","!","Default",":","0.5.","patch_size",":","The","patch","size","that","was","used","for","training","the","network",".","Do","not","use","different","patch","sizes","here",",","this","will","either","crash","or","give","potentially","less","accurate","segmentations",".","Default",":","None",".","regions_class_order",":","Return","region","class","by","given","order",".","Default",":","None",".","use_gaussian",":","(","Only","applies","to","sliding","window","prediction",")","If","True",",","uses","a","Gaussian","importance","weighting","to","weigh","predictions","closer","to","the","center","of","the","current","patch","higher","than","those","at","the","borders",".","The","reason","behind","this","is","that","the","segmentation","accuracy","decreases","towards","the","borders",".","Default","(","and","recommended",")",":","True","pad_border_mode",":","The","type","of","padding","image","border",".","Default",":","'constant","'",".","pad_kwargs",":","Parameters","for","padding","image","border",".","Default",":","NOne",".","verbose",":","Whether","print","log",".","Default",":","True",".","mixed_precision",":","Whether","use","amp","in","inference",".","Default",":","True","."]
code: def predict_3D(
      self,
      x: np.ndarray,
      do_mirroring: bool,
      mirror_axes: Tuple[int, ...] = (0, 1, 2),
      use_sliding_window: bool = False,
      step_size: float = 0.5,
      patch_size: Tuple[int, ...] = None,
      regions_class_order: Tuple[int, ...] = None,
      use_gaussian: bool = False,
      pad_border_mode: str = "constant",
      pad_kwargs: dict = None,
      verbose: bool = True,
  ) -> Tuple[np.ndarray, np.ndarray]:
      """
      x: Input data. Must be a nd.ndarray of shape (c, x, y, z).
      do_mirroring: If True, use test time data augmentation in the form of mirroring.
      mirror_axes: Determines which axes to use for mirroing. Per default, mirroring is done along all three axes. Default: (0, 1, 2).
      use_sliding_window: if True, run sliding window prediction. Heavily recommended! Default: True.
      step_size: When running sliding window prediction, the step size determines the distance between adjacent
      predictions. The smaller the step size, the denser the predictions (and the longer it takes!). Step size is given
      as a fraction of the patch_size. 0.5 is the default and means that wen advance by patch_size * 0.5 between
      predictions. step_size cannot be larger than 1! Default: 0.5.
      patch_size: The patch size that was used for training the network. Do not use different patch sizes here,
      this will either crash or give potentially less accurate segmentations. Default: None.
      regions_class_order: Return region class by given order. Default: None.
      use_gaussian: (Only applies to sliding window prediction) If True, uses a Gaussian importance weighting
       to weigh predictions closer to the center of the current patch higher than those at the borders. The reason
       behind this is that the segmentation accuracy decreases towards the borders. Default (and recommended): True
      pad_border_mode: The type of padding image border. Default: 'constant'.
      pad_kwargs: Parameters for padding image border. Default: NOne.
      verbose: Whether print log. Default: True.
      mixed_precision: Whether use amp in inference. Default: True.
      """
      assert (
          step_size <= 1
      ), "step_size must be smaller than 1. Otherwise there will be a gap between consecutive predictions"
  
      if verbose:
          print(
              "debug: mirroring",
              do_mirroring,
              "mirror_axes",
              mirror_axes,
          )
  
      if pad_kwargs is None:
          pad_kwargs = {"constant_values": 0}
  
      assert len(x.shape) == 4, "data must have shape (c,x,y,z)"
  
      if self.threeD:
          if use_sliding_window:
              res = self._internal_predict_3D_3Dconv_tiled(
                  x,
                  step_size,
                  do_mirroring,
                  mirror_axes,
                  patch_size,
                  regions_class_order,
                  use_gaussian,
                  pad_border_mode,
                  pad_kwargs=pad_kwargs,
                  verbose=verbose,
              )
          else:
              res = self._internal_predict_3D_3Dconv(
                  x,
                  patch_size,
                  do_mirroring,
                  mirror_axes,
                  regions_class_order,
                  pad_border_mode,
                  pad_kwargs=pad_kwargs,
                  verbose=verbose,
              )
      else:
          if use_sliding_window:
              res = self._internal_predict_3D_2Dconv_tiled(
                  x,
                  patch_size,
                  do_mirroring,
                  mirror_axes,
                  step_size,
                  regions_class_order,
                  use_gaussian,
                  pad_border_mode,
                  pad_kwargs,
                  False,
              )
          else:
              res = self._internal_predict_3D_2Dconv(
                  x,
                  patch_size,
                  do_mirroring,
                  mirror_axes,
                  regions_class_order,
                  pad_border_mode,
                  pad_kwargs,
                  False,
              )
      return res
  
imports: import pickle
  import numpy
  from functools import partial
  from typing import Tuple, List, Union
  from scipy.ndimage.filters import gaussian_filter
  from paddle.inference import create_predictor, PrecisionType
  from paddle.inference import Config
  from tools.preprocess_utils import GenericPreprocessor, PreprocessorFor2D
  from nnunet.utils.utils import no_op, pad_nd_image
  from nnunet.transforms import default_2D_augmentation_params, default_3D_augmentation_params
label_desc: Use image node_id 3 for calling the StaticBasePredictor obj's underlying member method code with example usage: obj.predict_3D(x, do_mirroring, mirror_axes, use_sliding_window, step_size, patch_size, regions_class_order, use_gaussian, pad_border_mode, pad_kwargs, verbose) and returns: res