For nn.AdaptiveAvgPool2d, you just specify the output size, stride will always be 1 (every possible grid will be used to achieve the output size):
torch.nn.AdaptiveAvgPool2d(output_size) according to AdaptiveAvgPool2d — PyTorch 1.9.0 documentation
The formulas above I believe is to calculate kernel size given input size, output size, and stride, (i.e. the size of the grids)