def _try_merge_slice_slice(
    first_slice: Operator, second_slice: Operator, slice_dim: int
) -> bool:
    """
    This function tries to merge two consecutive slice ops with the following
    steps:
        * update the start_indices and end_indices fields of the second_slice
        * remove the first slice
    """
    first_slice_output = first_slice._attrs["outputs"][0]
    first_slice_input_shape = first_slice._attrs["inputs"][0].shape()
    second_slice_output = second_slice._attrs["outputs"][0]
    second_slice_output_shape = second_slice_output.shape()
    # note that all the dims of input_shape[slice_dim:] and output_shape[slice_dim:]
    # are static at this point
    for idx in range(slice_dim, first_slice_output._rank()):
        first_slice_dim_offset = first_slice._attrs["start_indices"][idx]
        # update the start and end indices of the second slice op
        new_start = second_slice._attrs["start_indices"][idx] + first_slice_dim_offset
        first_slice_input_dim = first_slice_input_shape[idx].value()
        # new start index exceeds the corresponding dim value of the first slice input shape
        if new_start >= first_slice_input_dim:
            return False
        new_end = new_start + second_slice_output_shape[idx].value()
        # new end index exceeds the corresponding dim value of the first slice input shape
        if new_end > first_slice_input_dim:
            return False
        first_slice_end = first_slice._attrs["end_indices"][idx]
        second_slice_end = second_slice._attrs["end_indices"][idx]
        if first_slice_end == MAX_INT32 == second_slice_end:
            new_end = MAX_INT32
        second_slice._attrs["start_indices"][idx] = new_start
        second_slice._attrs["end_indices"][idx] = new_end
    # remove the old strided op from the first cat's dst_ops
    transform_utils.remove_single_tensor_op_from_sorted_graph(first_slice)
    return True
This function tries to merge two consecutive slice ops with the following
steps:
* update the start_indices and end_indices fields of the second_slice
* remove the first slice
python/aitemplate/compiler/transform/transform_merge_slice_ops.py