import tensorflow as tf


        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.'
            h = x_shape[1] + pad_h0 + pad_h1
            w = x_shape[2] + pad_w0 + pad_w1
            pad_h1 += tf.mod(-h + bsize[1], bstrides[1])
            pad_w1 += tf.mod(-w + bsize[2], bstrides[2])
        return tf.pad(x, [[0, 0], [pad_h0, pad_h1], [pad_w0, pad_w1], [0, 0]])
    else:
        if bstrides is not None:
            assert bsize is not None, 'Must pass in bsize and bstrides together.'
            h = x_shape[1]
            w = x_shape[2]
            pad_h1 = tf.mod(-h + bsize[1], bstrides[1])
            pad_w1 = tf.mod(-w + bsize[2], bstrides[2])
            return tf.cond(
                tf.logical_or(tf.greater(pad_h1, 0), tf.greater(pad_w1, 0)),
