Assuming that the shape of the inptu to self.layer.attend1 is torch.Size([256, 64, 28, 28]) like you said above, this can be done using the following code:
X = torch.randn([256, 64, 28, 28])
Y = nn.Conv2d(64, 64, stride=2, padding=1, kernel_size=3)(X)
Z = nn.AdaptiveAvgPool2d(1)(Y)

print(Z.shape)