import torch
import torch.nn as nn

class Discriminator(nn.Module):
  def __init__(self, input_nc, ndf=64, norm_layer=nn.BatchNorm2d, use_sigmoid=False) :
    super(Discriminator, self).__init__()
    self.conv1 = nn.Sequential(
      nn.Conv2d(input_nc, ndf, kernel_size=4, stride=2, padding=1),
      nn.LeakyReLU(0.2, True)
      )
    self.conv2 = nn.Sequential(
      nn.Conv2d(ndf, ndf * 2, kernel_size=4, stride=2, padding=1),
      norm_layer(ndf * 2),
      nn.LeakyReLU(0.2, True)
      )
    self.conv3 = nn.Sequential(
      nn.Conv2d(ndf * 2, ndf * 4, kernel_size=4, stride=2, padding=1),
      norm_layer(ndf * 4),
      nn.LeakyReLU(0.2, True)
      )
    self.conv4 = nn.Sequential(
      nn.Conv2d(ndf * 4, ndf * 8, kernel_size=4, stride=2, padding=1),
      norm_layer(ndf * 8),
      nn.LeakyReLU(0.2, True)
      )
    
    if use_sigmoid:
      self.conv5 = nn.Sequential(
        nn.Conv2d(ndf * 8, 1, kernel_size=4, stride=2, padding=1),
        nn.Sigmoid()
        )
    else:
      self.conv5 = nn.Sequential(
        nn.Conv2d(ndf * 8, 1, kernel_size=4, stride=2, padding=1)
        )
    
    def forward(self, x):
      x = self.conv1(x)
      x = self.conv2(x)
      x = self.conv3(x)
      x = self.conv4(x)
      x = self.conv5(x)
      return x

[((235, 295), 'torch.nn.Conv2d', 'nn.Conv2d', (['input_nc', 'ndf'], {'kernel_size': '(4)', 'stride': '(2)', 'padding': '(1)'}), '(input_nc, ndf, kernel_size=4, stride=2, padding=1)\n', (244, 295), True, 'import torch.nn as nn\n'), ((303, 326), 'torch.nn.LeakyReLU', 'nn.LeakyReLU', (['(0.2)', '(True)'], {}), '(0.2, True)\n', (315, 326), True, 'import torch.nn as nn\n'), ((373, 432), 'torch.nn.Conv2d', 'nn.Conv2d', (['ndf', '(ndf * 2)'], {'kernel_size': '(4)', 'stride': '(2)', 'padding': '(1)'}), '(ndf, ndf * 2, kernel_size=4, stride=2, padding=1)\n', (382, 432), True, 'import torch.nn as nn\n'), ((467, 490), 'torch.nn.LeakyReLU', 'nn.LeakyReLU', (['(0.2)', '(True)'], {}), '(0.2, True)\n', (479, 490), True, 'import torch.nn as nn\n'), ((537, 600), 'torch.nn.Conv2d', 'nn.Conv2d', (['(ndf * 2)', '(ndf * 4)'], {'kernel_size': '(4)', 'stride': '(2)', 'padding': '(1)'}), '(ndf * 2, ndf * 4, kernel_size=4, stride=2, padding=1)\n', (546, 600), True, 'import torch.nn as nn\n'), ((635, 658), 'torch.nn.LeakyReLU', 'nn.LeakyReLU', (['(0.2)', '(True)'], {}), '(0.2, True)\n', (647, 658), True, 'import torch.nn as nn\n'), ((705, 768), 'torch.nn.Conv2d', 'nn.Conv2d', (['(ndf * 4)', '(ndf * 8)'], {'kernel_size': '(4)', 'stride': '(2)', 'padding': '(1)'}), '(ndf * 4, ndf * 8, kernel_size=4, stride=2, padding=1)\n', (714, 768), True, 'import torch.nn as nn\n'), ((803, 826), 'torch.nn.LeakyReLU', 'nn.LeakyReLU', (['(0.2)', '(True)'], {}), '(0.2, True)\n', (815, 826), True, 'import torch.nn as nn\n'), ((902, 959), 'torch.nn.Conv2d', 'nn.Conv2d', (['(ndf * 8)', '(1)'], {'kernel_size': '(4)', 'stride': '(2)', 'padding': '(1)'}), '(ndf * 8, 1, kernel_size=4, stride=2, padding=1)\n', (911, 959), True, 'import torch.nn as nn\n'), ((969, 981), 'torch.nn.Sigmoid', 'nn.Sigmoid', ([], {}), '()\n', (979, 981), True, 'import torch.nn as nn\n'), ((1044, 1101), 'torch.nn.Conv2d', 'nn.Conv2d', (['(ndf * 8)', '(1)'], {'kernel_size': '(4)', 'stride': '(2)', 'padding': '(1)'}), '(ndf * 8, 1, kernel_size=4, stride=2, padding=1)\n', (1053, 1101), True, 'import torch.nn as nn\n')]