import tensorflow as tf

        blk_indices_crop = blk_indices[:, 0, 0, :]

        #  Project back to an image.
        y = tf.scatter_nd(blk_indices_crop, q, out_shape)
        return y

    with tf.control_dependencies([assert_shape, assert_strides]):
        return tf.cond(
            tf.equal(tf.size(blk_indices_), 0), lambda: tf.zeros(out_shape, dtype=x.dtype),
            _conv_nonzero)


def mask_conv2d(x, w, mask, strides, padding):
    """Masked 2D convolution. Used to check 2D sparse convolution.

    :param x:         [Tensor]    Convolution feature map, 4D, dtype float32.
