Hi,
Pytorch does not have all the segmentation ops like tensorflow.
The best way to do this depends on how you have the tensors to start with. If they’re already in one Tensor with padding, then keep it that way. If you have a small number of them or widely different sizes , a for-loop will be better. If you have many with similar sizes, creating the padded Tensor might be interesting.