Sure, you can swap the axes to get the desired shape using .permute()
>>> a =torch.randn(32, 14, 14, 2048)
>>> a.shape
torch.Size([32, 14, 14, 2048])

>>> a = a.permute(0, 3, 1, 2)
>>> a.shape
torch.Size([32, 2048, 14, 14])

Once you have the tensor in this correct shape, then you can apply avg_pool2d as I said previously.