# Buggy code
def __init__(
    self,
    output_dir: str = "./",
    output_postfix: str = "seg",
    output_ext: str = ".nii.gz",
    resample: bool = True,
    mode: Union[GridSampleMode, str] = GridSampleMode.BILINEAR,
    padding_mode: Union[GridSamplePadMode, str] = GridSamplePadMode.BORDER,
    dtype: Optional[np.dtype] = None,
) -> None:
    """
    Args:
        output_dir: output image directory.
        output_postfix: a string appended to all output file names.
        output_ext: output file extension name.
        resample: whether to resample before saving the data array.
        mode: {``"bilinear"``, ``"nearest"``}
            This option is used when ``resample = True``.
            Interpolation mode to calculate output values. Defaults to ``"bilinear"``.
            See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample
        padding_mode: {``"zeros"``, ``"border"``, ``"reflection"``}
            This option is used when ``resample = True``.
            Padding mode for outside grid values. Defaults to ``"border"``.
            See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample
        dtype: convert the image data to save to this data type.
            If None, keep the original type of data.
    """
    self.output_dir = output_dir
    self.output_postfix = output_postfix
    self.output_ext = output_ext
    self.resample = resample
    self.mode: GridSampleMode = GridSampleMode(mode)
    self.padding_mode: GridSamplePadMode = GridSamplePadMode(padding_mode)
    self.dtype = dtype
    self._data_index = 0


# Traceback (AssertionError)
======================================================================
FAIL: test_training (__main__.IntegrationSegmentation3D)
----------------------------------------------------------------------
Traceback (most recent call last):
File "tests/test_integration_segmentation_3d.py", line 257, in test_training
rtol=1e-3,
File "/opt/conda/lib/python3.6/site-packages/numpy/testing/_private/utils.py", line 1533, in assert_allclose
verbose=verbose, header=header, equal_nan=equal_nan)
File "/opt/conda/lib/python3.6/site-packages/numpy/testing/_private/utils.py", line 846, in assert_array_compare
raise AssertionError(msg)
AssertionError:
Not equal to tolerance rtol=0.001, atol=0

Mismatched elements: 6 / 6 (100%)
Max absolute difference: 0.01720129
Max relative difference: 0.04047175
x: array([0.543151, 0.471052, 0.453605, 0.438546, 0.437794, 0.407818])
y: array([0.544673, 0.475109, 0.444963, 0.427036, 0.433381, 0.42502 ])

----------------------------------------------------------------------
Ran 1 test in 92.377s

FAILED (failures=1)

# Fixed code
def __init__(
    self,
    output_dir: str = "./",
    output_postfix: str = "seg",
    output_ext: str = ".nii.gz",
    resample: bool = True,
    mode: Union[GridSampleMode, str] = GridSampleMode.BILINEAR,
    padding_mode: Union[GridSamplePadMode, str] = GridSamplePadMode.BORDER,
    align_corners: bool = False,
    dtype: Optional[np.dtype] = np.float64,
) -> None:
    """
    Args:
        output_dir: output image directory.
        output_postfix: a string appended to all output file names.
        output_ext: output file extension name.
        resample: whether to resample before saving the data array.
        mode: {``"bilinear"``, ``"nearest"``}
            This option is used when ``resample = True``.
            Interpolation mode to calculate output values. Defaults to ``"bilinear"``.
            See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample
        padding_mode: {``"zeros"``, ``"border"``, ``"reflection"``}
            This option is used when ``resample = True``.
            Padding mode for outside grid values. Defaults to ``"border"``.
            See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample
        align_corners: Geometrically, we consider the pixels of the input as squares rather than points.
            See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample
        dtype: data type for resampling computation. Defaults to ``np.float64`` for best precision.
            If None, use the data type of input data. To be compatible with other modules,
            the output data type is always ``np.float32``.
    """
    self.output_dir = output_dir
    self.output_postfix = output_postfix
    self.output_ext = output_ext
    self.resample = resample
    self.mode: GridSampleMode = GridSampleMode(mode)
    self.padding_mode: GridSamplePadMode = GridSamplePadMode(padding_mode)
    self.align_corners = align_corners
    self.dtype = dtype
    self._data_index = 0