Which one is correct to implement global adaptive pooling 3d?

I found three ways to implement global adaptive pooling for tensor size of BxCxDxHxW, or 5D tensor

Way 1

out = F.adaptive_avg_pool3d(input, kernel=(input.size(2),input.size(3), input.size(4)), stride =(1,1,1)
out = out.view(input(0), input(1))

Way 2:

out = out.view(input(0), input(1))


out= input_tensor.view(input.size(0), input.size(1), -1).mean(dim=2)
out = out.view(input(0), input(1))

If three ways are same, which one is recommended ?

The three ways are same, but I’m kind of confused about implementation #1: shouldn’t you specify a output_size parameter either, like you do in implementation #2?