def _get_rightmost_non_dynamic_dim(shape: List[IntVar]) -> Optional[int]:
    """
    Return the index of the rightmost non-dynamic dim. For example, given
    a shape [3, dyn_dim, 4, 1], it would return 2, which is the index of the
    third dim.
    Return None if shape[-1] is dynamic.
    """
    idx = 0
    for dim in reversed(shape):
        if not isinstance(dim, IntImm):
            break
        idx += 1
    if idx == 0:
        return None
    return len(shape) - idx
Return the index of the rightmost non-dynamic dim. For example, given
a shape [3, dyn_dim, 4, 1], it would return 2, which is the index of the
third dim.
Return None if shape[-1] is dynamic.
python/aitemplate/compiler/transform/transform_merge_slice_ops.py