code: def __init__(self, in_channels=3, out_channels=3):
      super(Generator, self).__init__()
  
      ##### Encoder #####
      def convblock(
          n_input,
          n_output,
          k_size=4,
          stride=2,
          padding=1,
          normalize=True,
      ):
          block = [
              nn.Conv2d(
                  n_input,
                  n_output,
                  kernel_size=k_size,
                  stride=stride,
                  padding=padding,
                  bias=False,
              )
          ]
          if normalize:
              block.append(nn.BatchNorm2d(n_output))
          block.append(nn.LeakyReLU(0.2, inplace=True))
          return block
  
      g_layers = [
          64,
          128,
          256,
          512,
          512,
          512,
          512,
          512,
      ]  # Generator feature maps (ref: pix2pix paper)
      self.encoder = nn.ModuleList(
          convblock(in_channels, g_layers[0], normalize=False)
      )  # 1st layer is not normalized.
      for iter in range(1, len(g_layers)):
          self.encoder += convblock(g_layers[iter - 1], g_layers[iter])
      # Ex.: Why use ModuleList instead of python lists?
  
      ##### Decoder #####
      def convdblock(
          n_input, n_output, k_size=4, stride=2, padding=1, dropout=0.0
      ):
          block = [
              nn.ConvTranspose2d(
                  n_input,
                  n_output,
                  kernel_size=k_size,
                  stride=stride,
                  padding=padding,
                  bias=False,
              ),
              nn.BatchNorm2d(n_output),
          ]
          if (
              dropout
          ):  # Mixing BN and Dropout is not recommended in general.
              block.append(nn.Dropout(dropout))
          block.append(nn.ReLU(inplace=True))
          return block
  
      d_layers = [512, 1024, 1024, 1024, 1024, 512, 256, 128]
      self.decoder = nn.ModuleList(
          convdblock(g_layers[-1], d_layers[0])
      )
      for iter in range(1, len(d_layers) - 1):
          self.decoder += convdblock(
              d_layers[iter], d_layers[iter + 1] // 2
          )
  
      self.model = nn.Sequential(
          nn.ConvTranspose2d(d_layers[-1], out_channels, 4, 2, 1),
          nn.Tanh(),
      )
  
file_path: gans-with-pytorch/pix2pix/models.py
imports: import torch
  from torch import nn
  import torch.nn.functional
label_desc: Use image node_id 1 to create a new Generator object from inherited base classes: nn with example: obj = Generator(in_channels, out_channels)