def gen_function(func_attrs: Dict[str, Any], header_files: str, backend_spec) -> str:
    """Generates function.

    Parameters
    ----------
    func_attrs : Dict[str, Any]
        Stores the operation attributes.
    header_files : str
        Includes the header files for a backend.
    backend_spec : class
        Specifies the backend configurations.

    Returns
    -------
    str
        Rendered function.
    """
    index_type = backend_spec.index_type
    prefix = backend_spec.prefix
    dtype = backend_spec.dtype_to_backend_type(func_attrs["inputs"][0]._attrs["dtype"])
    return FUNC_TEMPLATE.render(
        header_files=header_files,
        func_signature=FUNC_SIGNATURE.render(
            func_name=func_attrs["name"], index_type=index_type, prefix=prefix
        ),
        kernel=KERNEL_TEMPLATE.render(cub=backend_spec.cub, prefix=prefix),
        dtype=dtype,
    )
Generates function.

Parameters
----------
func_attrs : Dict[str, Any]
Stores the operation attributes.
header_files : str
Includes the header files for a backend.
backend_spec : class
Specifies the backend configurations.

Returns
-------
str
Rendered function.
python/aitemplate/backend/common/tensor/topk_common.py