Thanks, I think I got it better now. You can always repeat on centroid, say the last one, in order to stack all centroids into one single tensor. You just need to take n as the max size of the centroids for all t. The snippet above can be easily adapted to this case. I guess the desired output should be of the shape (t, m), is that right ?