def gen_function(
    func_attrs: Dict[str, Any],
    shape_eval_template: jinja2.Template,
    exec_template: jinja2.Template,
    extra_header_template: jinja2.Template,
    get_func_signature: Any,
) -> str:
    """Generate function body.

    Parameters
    ----------
    func_attrs : Dict
        Operation attributes.
    exec_template : jinja2.Template
        Execution block template.
    extra_header_template : jinja2.Template
        Extra header template.

    Returns
    -------
    str
        The rendered template of generated function body.
    """
    rank = func_attrs["inputs"][0]._rank()
    eps = func_attrs.get("eps", "1e-5")
    input_accessor = func_attrs["input_accessors"][0]
    output_accessor = func_attrs["output_accessors"][0]
    input_strides = []
    output_strides = []
    for i, _ in enumerate(input_accessor.original_shapes):
        input_strides.append(input_accessor.stride(i))
        output_strides.append(output_accessor.stride(i))

    input_offset = input_accessor.offset
    output_offset = output_accessor.offset

    exec_path = func_attrs["exec_path"]
    op_instance = func_attrs["op_instance"]

    inst_def_flag = set()
    instances = {}
    instance_decl = ""
    for exec_item in exec_path.values():
        fname = "f" + sha1(exec_item.exec_cond.encode()).hexdigest()
        algo = exec_item.algo
        if algo not in inst_def_flag:
            config = norm_common.emit_instance(op_instance[algo])
            inst_def_flag.add(algo)
        else:
            config = ""
        inst = norm_common.INSTANCE_TEMPLATE.render(
            config=config,
            name=fname,
            config_name=norm_common.extract_config_name(config),
        )
        instances[exec_item.exec_cond] = inst
        instance_decl += inst

    shape_eval = shape_eval_template.render(rank=rank) if shape_eval_template else ""
    exec_cond_template = func_attrs["exec_cond_template"]
    exec_paths = ""
    for key, _ in instances.items():
        fname = "f" + sha1(key.encode()).hexdigest()
        program = exec_template.render(
            instance=fname,
            dtype="void",
            reduce_dims=rank - 1,
            eps=eps,
            input_strides=input_strides,
            output_strides=output_strides,
            input_offset=input_offset,
            output_offset=output_offset,
        )
        exec_inst = exec_cond_template.render(indent="  ", cond=key, program=program)
        exec_paths += exec_inst

    return norm_common.FUNC_TEMPLATE.render(
        instances_decl=instance_decl,
        func_signature=get_func_signature(func_attrs),
        shape_eval=shape_eval,
        exec_paths=exec_paths,
        extra_headers=extra_header_template.render(),
    )
Generate function body.

Parameters
----------
func_attrs : Dict
Operation attributes.
exec_template : jinja2.Template
Execution block template.
extra_header_template : jinja2.Template
Extra header template.

Returns
-------
str
The rendered template of generated function body.
python/aitemplate/backend/rocm/normalization/layernorm.py