As @smth says, you can use torch,mean for global average pooling. Another way is by torch.nn.AvgPool2d(kernel_size=feature_size).  This way you need to find out the size of the input features, and apply pooling with kernel size as big as your feature size.