I think there are some corrections,
your 4th line in keras model says output should have 64 channels, in pytorch you are declaring 32*64 channels, we need to work on that. Because, In pytorch we need to declare just number of channels for the input, number of channels for the output, it takes care of the spatial sizes
Also, once we do resize the network only once before we pass it through a linear we don’t need to do it every time it goes through a linear layer.
class NeuralNet(nn.Module):
  
    def __init__(self):
        super(NeuralNet, self).__init__()

        self.conv1 = nn.Conv2d(1, 32, kernel_size=(3,3))
        self.pool1 = nn.MaxPool2d(2)
        self.drop1 = nn.Dropout(0.25)

        self.conv2 = nn.Conv2d(32, 64, kernel_size=(3,3))
        self.pool2 = nn.MaxPool2d(2)
        self.drop2 = nn.Dropout(0.25)

        self.linear3 = nn.Linear(64*5*5, 256)
        self.drop3 = nn.Dropout(0.5)

        self.linear4 = nn.Linear(256,10)
        self.relu = nn.ReLU()
        self.softmax = nn.Softmax()
        
    def forward(self, x):
        x = self.relu(self.conv1(x))
        x = self.pool1(x)
        x = self.drop1(x)
        
        x = self.relu(self.conv2(x))
        x = self.pool2(x)
        x = self.drop2(x)
        
        x = x.view(x.size(0), -1)
        x = self.relu(self.linear3(x))
        x = self.drop3(x)
        x = self.linear4(x)
        return x
              
model = NeuralNet()

batch_size, C, H, W = 1, 1, 28, 28
x = torch.randn(batch_size, C, H, W)
output = model(x)