import tensorflow as tf

    :param x:        [Tensor]   [N, H, W, C]. input tensor, dtype float32.
    :param ksize:    [list]     List of 4 int. Sparse convolution kernel size.
    :param strides:  [list]     List of 4 int. Sparse convolution stride size.
    :param padding:  [string]   `VALID` or `SAME`, padding method for sparse convolution.
    :param bsize     [list]     List of 4 int. Block size. Optional.
    :param bstrides: [list]     List of 4 int. Block strides. Optional.

    :return          [Tensor]   [N, H+Ph, W+Pw, C]. Padded input tensor.
    """
    x_shape = tf.shape(x)
    if padding == 'SAME':
        pad_h0, pad_h1, pad_w0, pad_w1 = calc_padding_4d(x_shape, ksize, strides, padding)

        if bstrides is not None:
            # Here we do not use the standard padding on the right hand side.
            # If the convolution results is larger than expected, the scatter function will not use
            # out-of-boundary points.
            assert bsize is not None, 'Must pass in bsize and bstrides together.'
