I’d look at the third-party package PyTorch scatter 1. It has a reduction=mean mode.
You need to convert lst to a tensor and possibly use broadcasting.
Now, the scatter implementation uses atomics, which is problematic e.g. in terms of performance. If the partitions are ordered (as your example suggests), you might compare to just doing a for loop and taking means over the slices.
Best regards
Thomas