Consider using the following pattern: 

    if self.dim == 2: 
        if interpolation == 'lin':
            warper = vfu.warp_image
        else:
            warper = vfu.warp_image_nn
    else: 
        if interpolation == 'lin':
           warper = vfu.warp_volume
        else:
            warper = vfu.warp_volume_nn

    warped = warper(image, self.forward,
                                   affine_idx_in,
                                   affine_idx_out,
                                   affine_disp,
                                   sampling_shape)