def gen_function(
    func_attrs: Dict[str, Any],
    template_path: str,
    header_files: str,
    backend_spec,
) -> str:
    """
    Parameters
    ----------
    func_attrs : Dict[str, Any]
        Attributes from Operator
    template_path : str
        path to library used
    header_files : str
        header files included in the function
    backend_spec : class
        specifies backend configs

    Returns
    -------
    str
        Source code for function generated.
    """
    func_name = func_attrs["name"]
    x = func_attrs["inputs"][0]
    tensor_accessor = func_attrs["input_accessors"][0]
    xdtype = x._attrs["dtype"]
    tensor_accessor_libs = tensor_accessor_codegen.get_libs()
    input_accessor_name = "input_accessor"
    input_accessor = tensor_accessor_codegen.TENSOR_ACCESSOR_TEMPLATE.render(
        name=input_accessor_name, tensor_accessor=tensor_accessor
    )
    exec_paths = EXEC_TEMPLATE.render(input_accessor_def=input_accessor)

    return SRC_TEMPLATE.render(
        function_name=func_name,
        exec_paths=exec_paths,
        header_files=header_files,
        lib_dtype=backend_spec.dtype_to_lib_type(xdtype),
        prefix=backend_spec.prefix,
        tensor_accessor_libs=tensor_accessor_libs,
    )
Parameters
----------
func_attrs : Dict[str, Any]
Attributes from Operator
template_path : str
path to library used
header_files : str
header files included in the function
backend_spec : class
specifies backend configs

Returns
-------
str
Source code for function generated.
python/aitemplate/backend/common/tensor/permute021_common.py