def gen_function(func_attrs: Dict[str, Any], header_files: str, backend_spec) -> str:
    """the function for generating nms kernel"""
    blockSize = 1024
    t_size = int((func_attrs["preNmsTop"] + blockSize - 1) / blockSize)
    if backend_spec.backend_name == "cuda":
        cuda_hmaxmin = True
    else:
        cuda_hmaxmin = False

    elem_rois_type = backend_spec.dtype_to_backend_type(
        func_attrs["inputs"][0]._attrs["dtype"]
    )
    elem_scores_type = backend_spec.dtype_to_backend_type(
        func_attrs["inputs"][1]._attrs["dtype"]
    )
    return FUNC_TEMPLATE.render(
        T_SIZE=t_size,
        elem_scores_type=elem_scores_type,
        elem_rois_type=elem_rois_type,
        header_files=header_files,
        kernel=KERNEL_TEMPLATE.render(
            prefix=backend_spec.prefix, cub=backend_spec.cub, cuda_hmaxmin=cuda_hmaxmin
        ),
        func_signature=FUNC_SIGNATURE.render(
            func_name=func_attrs["name"],
            prefix=backend_spec.prefix,
            index_type=backend_spec.index_type,
        ),
    )
the function for generating nms kernel
python/aitemplate/backend/common/vision_ops/nms_common.py