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

    Returns
    -------
    str
        The function body string
    """
    backend_spec = CUDASpec()
    x = func_attrs["inputs"][0]
    y = func_attrs["outputs"][0]
    dim = func_attrs["dim"]

    input_type = backend_spec.dtype_to_backend_type(x._attrs["dtype"])
    output_type = backend_spec.dtype_to_backend_type(y._attrs["dtype"])

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

    read_t = backend_spec.get_elementwise_read_backend_type(
        shape_utils.get_num_rightmost_static_elements(
            y.shape(), len(x.shape()) - dim - 1
        ),
        y.dtype(),
    )
    data_t = backend_spec.dtype_to_backend_type(y.dtype())
    read_vector_length = int(
        backend_spec.sizeof_types[read_t] / backend_spec.sizeof_types[data_t]
    )

    return SRC_TEMPLATE.render(
        input_type=input_type,
        index_type=backend_spec.index_type,
        func_name=func_attrs["name"],
        header_files=header_files,
        read_t=read_t,
        read_vector_length=read_vector_length,
    )
Generate function body

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