def jagged_to_padded_dense_gen_function(func_attrs: Dict[str, Any]) -> str:
    """Generates jagged_to_padded_dense function definition."""

    x = func_attrs["inputs"][0]
    y = func_attrs["outputs"][0]
    jagged_int_var = x.shape()[0]
    backend_spec = CUDASpec()

    dtype = x.dtype()
    data_type = backend_spec.dtype_to_backend_type(dtype)

    # inner size of the input jagged Tensor: can't use the output dense Tensor
    # shape here, as some the dimensions in it may overlap with the jagged
    # dimensions of the input jagged Tensor
    inner_size = shape_utils.get_num_rightmost_static_elements(x.shape())
    read_type = backend_spec.get_elementwise_read_backend_type(inner_size, dtype)

    kernel_function = _gen_kernel_function(
        func_attrs=func_attrs,
        index_type=backend_spec.index_type,
        data_type=data_type,
        read_type=read_type,
    )

    constant = CONSTANT_TEMPLATE.render(
        read_t=read_type,
        data_t=data_type,
        op_t=data_type,
    )

    dynamic_dims = get_dynamic_dims(y.shape())

    return FUNC_TEMPLATE.render(
        prefix=backend_spec.prefix,
        index_type=backend_spec.index_type,
        head=backend_spec.header_src_template.render(),
        constant=constant,
        kernel_function=kernel_function,
        func_name=func_attrs["name"],
        dynamic_dims_decl=gen_dynamic_dim_str(
            index_type=backend_spec.index_type,
            dynamic_dims=dynamic_dims,
            has_type=True,
        ),
        dynamic_dims_call=gen_dynamic_dim_str(
            index_type=backend_spec.index_type,
            dynamic_dims=dynamic_dims,
            has_type=False,
        ),
        offsets_decl=gen_offsets_str(
            jagged_int_var=jagged_int_var,
            has_type=True,
            # the offsets are passed
            # by const reference to the function
            const_ref=True,
            name="offsets",
        ),
        offsets_call=gen_offsets_str(
            jagged_int_var=jagged_int_var,
            has_type=False,
            const_ref=False,
            name="offsets",
        ),
        read_t=read_type,
    )
Generates jagged_to_padded_dense function definition.
python/aitemplate/backend/cuda/tensor/jagged_to_padded_dense.py