@triton.jit
def dequant_nf4_tensor_kernel(inpt_ptr, output_ptr, quantized_scalers_ptr,
    quantization_factor_ptr, scaler_mean_ptr, nf4_lut_ptr,
    scaler_block_size: tl.constexpr, XBLOCK: tl.constexpr):
    """Dequantizes a tensor from nf4 to bfloat16"""
    offset = tl.program_id(0) * XBLOCK
    index = offset + tl.arange(0, XBLOCK)[:]
    index = tl.max_contiguous(tl.multiple_of(index, XBLOCK), XBLOCK)
    inpt = tl.load(inpt_ptr + index)
    first_elements = inpt >> 4
    second_elements = inpt & 15
    dequantized_first = dequantize(first_elements, nf4_lut_ptr)
    dequantized_second = dequantize(second_elements, nf4_lut_ptr)
    block_scaler = dequantize_scalers(quantized_scalers_ptr,
        quantization_factor_ptr, scaler_mean_ptr, XBLOCK, scaler_block_size)
    scaled_first = dequantized_first * block_scaler
    scaled_second = dequantized_second * block_scaler
    store_indices = offset * 2 + tl.arange(0, XBLOCK * 2)[:]
    interleaved = tl.interleave(scaled_first, scaled_second)
    tl.store(output_ptr + store_indices, interleaved)
