Thanks - here is the working example
import torch
import torch.nn.functional as F

t = torch.rand(20, 2048, 1, 1)
print(t.shape)
t = t.permute(2, 1, 0, 3)
print(t.shape)
t = F.adaptive_avg_pool2d(t, 1)
print(t.shape)
t = t.view(1, 2048)
print(t.shape)

returns
torch.Size([20, 2048, 1, 1])
torch.Size([1, 2048, 20, 1])
torch.Size([1, 2048, 1, 1])
torch.Size([1, 2048])