The kernel size of your pooling layers is odd, which makes to manual calculation sometimes a bit tedious.
You could just print the shape after each layer:
class Net(nn.Module):
    def __init__(self):
        super(Net, self).__init__()
        self.conv1 = nn.Conv2d(1, 32, kernel_size=3, stride=(1, 1))
        self.conv2 = nn.Conv2d(32, 64, kernel_size=3, stride=(1, 1))
        self.conv3 = nn.Conv2d(64, 32, kernel_size=3, stride=(1, 1), padding=1)
        self.fc1 = nn.Linear(128, 4096)
        self.fc2 = nn.Linear(4096, 10)
        
    def forward(self, x):
        x = F.relu(self.conv1(x))  # 26
        print(x.shape)
        x = F.relu(self.conv2(x))  # 24
        print(x.shape)
        x = F.max_pool2d(x, 3)  # 8
        print(x.shape)
        x = F.relu(self.conv3(x))  # 8
        print(x.shape)
        x = F.max_pool2d(x, 3)  # 2
        print(x.shape)
        x = x.view(-1, 128)
        x = F.relu(self.fc1(x))
        x = F.dropout(x, training=self.training)
        x = self.fc2(x)
        return F.log_softmax(x, dim = 0)

As you can see, you’ll get an activation of 32*2*2, which fits the number of input features.