import tensorflow as tf

            return blk_indices_crop

        def _strides_one():
            # Calculate otuput indices when strides = 1.
            return blk_indices[:, :q_shape[1], :q_shape[2], :]

        strides_gt_one = tf.logical_or(tf.greater(strides[1], 1), tf.greater(strides[2], 1))
        blk_indices_crop = tf.cond(strides_gt_one, _strides_gt_one, _strides_one)
        y = tf.scatter_nd(blk_indices_crop, q, out_shape)
        return y

    return tf.cond(
        tf.equal(tf.size(blk_indices_), 0), lambda: tf.zeros(out_shape, dtype=x.dtype),
        _conv_nonzero)


# returns an int64 start timer handle that should be passed to cuda_timer_end_op
def cuda_timer_start_op():
    return sbnet_module.cuda_timer_start()


# returns a float
def cuda_timer_end_op(start_timer):
    return sbnet_module.cuda_timer_end(start_timer)
