def grouped_fmha_style_b2b_bmm_gen_function(func_attrs: Dict[str, Any]) -> str:
    """the function for generating attention kernel"""
    q, k, v = func_attrs["inputs"][0:3]

    bias_broadcast = [False] * 4
    if len(func_attrs["inputs"]) > 3:
        bias = func_attrs["inputs"][3]
        bias_broadcast = [var == IntImm(1) for var in bias.shape()]

    jagged_dim = q._attrs["shape"][0]
    head_dim = q._attrs["shape"][2]
    head_dim_value = v._attrs["shape"][2]
    if not isinstance(head_dim, IntImm) or not isinstance(head_dim_value, IntImm):
        raise RuntimeError(
            f"head_dim and head_dim_value must be static dims. {func_attrs['name']=}, {head_dim=}, {head_dim_value=}"
        )
    backend_spec = CUDASpec()
    elem_input_type = backend_spec.dtype_to_lib_type(
        func_attrs["inputs"][0]._attrs["dtype"]
    )
    elem_output_type = backend_spec.dtype_to_lib_type(
        func_attrs["outputs"][0]._attrs["dtype"]
    )
    elem_accum_type = elem_input_type
    if (
        elem_input_type == "cutlass::half_t"
        and "use_fp16_acc" in Target.current()._kwargs
        and not Target.current()._kwargs["use_fp16_acc"]
    ):
        elem_accum_type = "float"

    import cutlass_lib

    activation_functor = cutlass_lib.library.EpilogueMathTag[
        cutlass_lib.library.EpilogueMathName[func_attrs["epilogue_math_name"]]
    ]
    return fmha_style_b2b_bmm.FUNC_TEMPLATE.render(
        func_name=func_attrs["name"],
        func_signature=FUNC_SIGNATURE.render(func_name=func_attrs["name"]),
        elem_input_type=elem_input_type,
        elem_output_type=elem_output_type,
        elem_accum_type=elem_accum_type,
        offset_t=jagged_dim.offsets_type(),
        seq_length="max_seq_length",
        seq_length_kv="max_seq_length",
        head_dim=str(head_dim.value()),
        head_dim_value=str(head_dim_value.value()),
        causal_type=fmha_style_b2b_bmm.causal_type_to_kernel_str(
            func_attrs["causal_type"]
        ),
        num_heads="num_heads",
        alpha0=str(func_attrs["alpha0"]),
        alpha1=str(func_attrs["alpha1"]),
        alpha1_divide_by_seq_len=(
            "true" if func_attrs["alpha1_divide_by_seq_len"] else "false"
        ),
        activation_functor=activation_functor,
        bias_broadcast=bias_broadcast,
        offset_ptr="offset",
    )
the function for generating attention kernel
python/aitemplate/backend/cuda/b2b_bmm/grouped_fmha_style_b2b_bmm.py