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

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

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

    # inner size of the output jagged Tensor: can't use the input dense Tensor
    # shape here, as some the dimensions in it may overlap with the jagged
    # dimensions of the output jagged Tensor
    inner_size = shape_utils.get_num_rightmost_static_elements(y.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,
    )

    func_name = func_attrs["name"]
    dynamic_dims = get_dynamic_dims(x.shape(), y.shape())
    offsets_struct_type = jagged_int_var.offsets_struct_type()
    total_length = jagged_int_var.total_length()

    if total_length._attrs.get("isolated", False):
        raise ValueError(
            f"The {total_length._attrs['name']} (total_length) dimension "
            f"of the jagged Tensor output of {func_name} must be present in "
            "one of the input shapes, but it isn't."
        )

    return FUNC_TEMPLATE.render(
        prefix=backend_spec.prefix,
        index_type=backend_spec.index_type,
        head=backend_spec.header_src_template.render(),
        offsets_struct_type=offsets_struct_type,
        offsets_type=jagged_int_var.offsets_type(),
        num_offsets=len(jagged_int_var.jagged_dims()),
        constant=constant,
        kernel_function=kernel_function,
        func_name=func_name,
        calculate_n=_gen_calculate_n(
            input_shape=x.shape(),
            output_shape=y.shape(),
        ),
        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,
        ),
        read_t=read_type,
    )
Generates padded_dense_to_jagged function definition.
python/aitemplate/backend/cuda/tensor/padded_dense_to_jagged.py