In your example dim1 should be equal, so you could pad the second tensor with F.pad:
import torch.nn.functional as F
F.pad(torch.randn(5, 5), (2, 3, 0, 0))

Note that I’ve used a padding of 2 and 3 for the “left” and “right” side of dim1, but you could of course also only pad on one side with 5 values or chose any other valid configuration.