# Buggy code
def __init__(
    self,
    pixdim: Union[Sequence[float], float],
    diagonal: bool = False,
    mode: Union[GridSampleMode, str] = GridSampleMode.BILINEAR,
    padding_mode: Union[GridSamplePadMode, str] = GridSamplePadMode.BORDER,
    dtype: Optional[np.dtype] = None,
) -> None:
    """
    Args:
        pixdim: output voxel spacing.
        diagonal: whether to resample the input to have a diagonal affine matrix.
            If True, the input data is resampled to the following affine::

                np.diag((pixdim_0, pixdim_1, ..., pixdim_n, 1))

            This effectively resets the volume to the world coordinate system (RAS+ in nibabel).
            The original orientation, rotation, shearing are not preserved.

            If False, this transform preserves the axes orientation, orthogonal rotation and
            translation components from the original affine. This option will not flip/swap axes
            of the original data.
        mode: {``"bilinear"``, ``"nearest"``}
            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"``}
            Padding mode for outside grid values. Defaults to ``"border"``.
            See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample
        dtype: output array data type. Defaults to ``np.float32``.
    """
    self.pixdim = np.array(ensure_tuple(pixdim), dtype=np.float64)
    self.diagonal = diagonal
    self.mode: GridSampleMode = GridSampleMode(mode)
    self.padding_mode: GridSamplePadMode = GridSamplePadMode(padding_mode)
    self.dtype = dtype


# 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,
    pixdim: Union[Sequence[float], float],
    diagonal: bool = False,
    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:
        pixdim: output voxel spacing.
        diagonal: whether to resample the input to have a diagonal affine matrix.
            If True, the input data is resampled to the following affine::

                np.diag((pixdim_0, pixdim_1, ..., pixdim_n, 1))

            This effectively resets the volume to the world coordinate system (RAS+ in nibabel).
            The original orientation, rotation, shearing are not preserved.

            If False, this transform preserves the axes orientation, orthogonal rotation and
            translation components from the original affine. This option will not flip/swap axes
            of the original data.
        mode: {``"bilinear"``, ``"nearest"``}
            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"``}
            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.pixdim = np.array(ensure_tuple(pixdim), dtype=np.float64)
    self.diagonal = diagonal
    self.mode: GridSampleMode = GridSampleMode(mode)
    self.padding_mode: GridSamplePadMode = GridSamplePadMode(padding_mode)
    self.align_corners = align_corners
    self.dtype = dtype