def gen_function(func_attrs) -> str:
    """
    Generate function body

    Returns
    -------
    str
        The function body string
    """
    backend_spec = CUDASpec()
    x, mask = func_attrs["inputs"]
    output = func_attrs["outputs"][0]
    max_shape = func_attrs["max_shape"]

    input_type = cuda_common.dtype_to_cuda_type(x._attrs["dtype"])
    output_type = cuda_common.dtype_to_cuda_type(output._attrs["dtype"])

    if input_type != output_type:
        raise TypeError("input type must equal to output type")

    dynamic_dims = get_dynamic_dims(x.shape(), mask.shape())

    return SRC_TEMPLATE.render(
        input_type=input_type,
        index_type=backend_spec.index_type,
        func_name=func_attrs["name"],
        header_files=header_files,
        workspace_size=func_attrs["workspace"],
        input_dims=_get_dims(x.shape()),
        input_rank=len(x.shape()),
        input_strides=get_stride_expressions(x.shape()) + ["1"],
        need_broadcast_input=x._attrs["shape"] != max_shape,
        mask_dims=_get_dims(mask.shape()),
        mask_rank=len(mask.shape()),
        mask_strides=get_stride_expressions(mask.shape()) + ["1"],
        need_broadcast_mask=mask._attrs["shape"] != max_shape,
        max_dims=_get_dims(max_shape),
        max_rank=len(max_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,
        ),
    )

    Generate function body

    Returns
    -------
    str
        The function body string
    
python/aitemplate/backend/cuda/tensor/masked_select.py