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:
self.avg_pool=nn.AdaptiveAvgPool3d(1)
out=self.avg_pool(input)
out = out.view(input(0), input(1))

Way3:
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 ?