How to megre intermediary outputs in forward

I am confused how to megre all intermediary output in forward. In each loop, att1 have a shape (batch x 1 x 64 x64), i want pfeat have a shape (batch x num_parts x 64 x 64) .
When i run the below scipt.There comes the problem,AttributeError: ‘list’ object has no attribute 'size. How to fix this,Thanks for any help.

 def forward(self,x):
    pfeat = []
    if self.use_part is not None:
        for i in range(self.num_parts):
            att = self.attention(x)
            att1 = self.conv(att)
        return pfeat 
        return self.attention(x)

you may use

I have tried and torch.stack(). But it doesn’t works.Maybe I have misused.Thanks for your help.