The Discriminator uses a conv layer as it’s output (skip the nn.Sigmoid as it’s shape-independent), which makes it usable for different input shapes.
Once way to get a fixed output would be to use e.g. an adaptive pooling layer, which creates a defined spatial activation shape. Based on this comment:
# state size. (ndf*8) x 4 x 4

it seems the activation has a spatial shape of 4x4 before being passed to the last conv layer.
Add nn.Adaptive*Pool2d(output_size=(4, 4)) in front of the last conv layer and it should work (the * refers to the pooling modes such as Avg/Max etc.).