class_docstr: A 2D-conv downsampling block following best practices / with reasonable defaults
  (LeakyReLU, kernel size multiple of stride)
class_docstr_tok: ["A","2D-conv","downsampling","block","following","best","practices","\/","with","reasonable","defaults","(","LeakyReLU",",","kernel","size","multiple","of","stride",")"]
docstr: :param in_channels: Number of input channels
  :param out_channels: Number of output channels
  :param prep_conv: Whether to have another convolutional layer before the downsampling layer.
  :param middle_channels: If prep_conv is true, this sets the number of channels between the prep and downsampling
                          convs.
  :param use_dropout: bool. Whether to use dropout or not.
  :param dropout_prob: Float. The dropout probability (if use_dropout is True)
  :param norm: Which norm to use. If None, no norm is used. Default is Batchnorm with affinity.
docstr_tok: [":","param","in_channels",":","Number","of","input","channels",":","param","out_channels",":","Number","of","output","channels",":","param","prep_conv",":","Whether","to","have","another","convolutional","layer","before","the","downsampling","layer",".",":","param","middle_channels",":","If","prep_conv","is","true",",","this","sets","the","number","of","channels","between","the","prep","and","downsampling","convs",".",":","param","use_dropout",":","bool",".","Whether","to","use","dropout","or","not",".",":","param","dropout_prob",":","Float",".","The","dropout","probability","(","if","use_dropout","is","True",")",":","param","norm",":","Which","norm","to","use",".","If","None",",","no","norm","is","used",".","Default","is","Batchnorm","with","affinity","."]
code: def __init__(
      self,
      in_channels,
      out_channels,
      prep_conv=True,
      middle_channels=None,
      use_dropout=False,
      dropout_prob=0.1,
      norm=nn.BatchNorm2d,
  ):
      """
      :param in_channels: Number of input channels
      :param out_channels: Number of output channels
      :param prep_conv: Whether to have another convolutional layer before the downsampling layer.
      :param middle_channels: If prep_conv is true, this sets the number of channels between the prep and downsampling
                              convs.
      :param use_dropout: bool. Whether to use dropout or not.
      :param dropout_prob: Float. The dropout probability (if use_dropout is True)
      :param norm: Which norm to use. If None, no norm is used. Default is Batchnorm with affinity.
      """
      super().__init__()
  
      if middle_channels is None:
          middle_channels = in_channels
  
      net = list()
  
      if prep_conv:
          net += [
              nn.ReflectionPad2d(1),
              nn.Conv2d(
                  in_channels,
                  middle_channels,
                  kernel_size=3,
                  padding=0,
                  stride=1,
                  bias=True if norm is None else False,
              ),
          ]
  
          if norm is not None:
              net += [norm(middle_channels, affine=True)]
  
          net += [nn.LeakyReLU(0.2, True)]
  
          if use_dropout:
              net += [nn.Dropout2d(dropout_prob, False)]
  
      net += [
          nn.ReflectionPad2d(1),
          nn.Conv2d(
              middle_channels,
              out_channels,
              kernel_size=4,
              padding=0,
              stride=2,
              bias=True if norm is None else False,
          ),
      ]
  
      if norm is not None:
          net += [norm(out_channels, affine=True)]
  
      net += [nn.LeakyReLU(0.2, True)]
  
      if use_dropout:
          net += [nn.Dropout2d(dropout_prob, False)]
  
      self.net = nn.Sequential(*net)
  
imports: import torch
  import torch.nn
  import torchvision.utils
  from torch.nn import functional
label_desc: Use image node_id 1 to create a new DownBlock object from inherited base classes: nn with example: obj = DownBlock(in_channels, out_channels, prep_conv, middle_channels, use_dropout, dropout_prob, norm)