Padding a list of tensors

I have a list of 4D tensors of different sizes. I need to pad all of them per each dimension till the size of the biggest tensor for that dimension.
input_ten: [[1x1x2x3],

ouput_ten: [[1x2x4x3],

Is there any built-in/efficient function to do it?

I don’t think there’s a built-in way to do it.

import torch
x = torch.randn(1, 1, 2, 3)
y = torch.randn(1, 1, 4, 2)
z = torch.randn(1, 2, 1, 3)
tensors = [x, y, z]
output_shape = [max(sizes) for sizes in zip(*[x.size() for x in tensors])]

Here’s a way to get the output shape (1, 2, 4, 3) from your list, but I’m not really sure how to pad them in each dim.