docstr: Densely-Connected Convolutional Block.
  
  Args:
      in_channels (int): number of input channels
      out_channels (int): number of output channels
      hid_channels (int): number of output channels in intermediate Conv layers
      kernel_size (tuple): kernel size for all but the last Conv layers
      padding (tuple): padding for all but the last Conv layers
      last_kernel_size (tuple): kernel size for the last GluConv layer
      last_stride (tuple): stride for the last GluConv layer
      last_padding (tuple): padding for the last GluConv layer
      last_output_padding (tuple): output padding for the last GluConvTranspose2d
           (only used when `transposed=True`)
      layers (int): total number of Conv layers
      transposed (bool): True to use GluConvTranspose2d in the last layer
                         False to use GluConv2d in the last layer
docstr_tok: ["Densely-Connected","Convolutional","Block",".","Args",":","in_channels","(","int",")",":","number","of","input","channels","out_channels","(","int",")",":","number","of","output","channels","hid_channels","(","int",")",":","number","of","output","channels","in","intermediate","Conv","layers","kernel_size","(","tuple",")",":","kernel","size","for","all","but","the","last","Conv","layers","padding","(","tuple",")",":","padding","for","all","but","the","last","Conv","layers","last_kernel_size","(","tuple",")",":","kernel","size","for","the","last","GluConv","layer","last_stride","(","tuple",")",":","stride","for","the","last","GluConv","layer","last_padding","(","tuple",")",":","padding","for","the","last","GluConv","layer","last_output_padding","(","tuple",")",":","output","padding","for","the","last","GluConvTranspose2d","(","only","used","when","`","transposed=True","`",")","layers","(","int",")",":","total","number","of","Conv","layers","transposed","(","bool",")",":","True","to","use","GluConvTranspose2d","in","the","last","layer","False","to","use","GluConv2d","in","the","last","layer"]
code: def __init__(
      self,
      in_channels,
      out_channels,
      hid_channels=8,
      kernel_size=(1, 3),
      padding=(0, 1),
      last_kernel_size=(
          1,
          4,
      ),  # use (1, 4) to alleviate the checkerboard artifacts
      last_stride=(1, 2),
      last_padding=(0, 1),
      last_output_padding=(0, 0),
      layers=5,
      transposed=False,
  ):
      """Densely-Connected Convolutional Block.
  
      Args:
          in_channels (int): number of input channels
          out_channels (int): number of output channels
          hid_channels (int): number of output channels in intermediate Conv layers
          kernel_size (tuple): kernel size for all but the last Conv layers
          padding (tuple): padding for all but the last Conv layers
          last_kernel_size (tuple): kernel size for the last GluConv layer
          last_stride (tuple): stride for the last GluConv layer
          last_padding (tuple): padding for the last GluConv layer
          last_output_padding (tuple): output padding for the last GluConvTranspose2d
               (only used when `transposed=True`)
          layers (int): total number of Conv layers
          transposed (bool): True to use GluConvTranspose2d in the last layer
                             False to use GluConv2d in the last layer
      """
      super().__init__()
  
      assert layers > 1, layers
      self.conv = nn.ModuleList()
      in_channel = in_channels
      # here T=42 and D=127 are random integers that should not be changed after Conv
      T, D = 42, 127
      hidden_sizes = [127]
      for _ in range(layers - 1):
          self.conv.append(
              nn.Sequential(
                  nn.Conv2d(
                      in_channel,
                      hid_channels,
                      kernel_size=kernel_size,
                      stride=(1, 1),
                      padding=padding,
                  ),
                  nn.BatchNorm2d(hid_channels),
                  nn.ELU(inplace=True),
              )
          )
          in_channel = in_channel + hid_channels
          # make sure the last two dimensions will not be changed after this layer
          tdim, hdim = conv2d_output_shape(
              (T, D),
              kernel_size=kernel_size,
              stride=(1, 1),
              pad=padding,
          )
          hidden_sizes.append(hdim)
          assert tdim == T and hdim == D, (tdim, hdim, T, D)
  
      if transposed:
          self.conv.append(
              GluConvTranspose2d(
                  in_channel,
                  out_channels,
                  kernel_size=last_kernel_size,
                  stride=last_stride,
                  padding=last_padding,
                  output_padding=last_output_padding,
              )
          )
      else:
          self.conv.append(
              GluConv2d(
                  in_channel,
                  out_channels,
                  kernel_size=last_kernel_size,
                  stride=last_stride,
                  padding=last_padding,
              )
          )
  
imports: from typing import List
  import torch
  import torch.nn
  from espnet2.enh.layers.conv_utils import conv2d_output_shape, convtransp2d_output_shape
label_desc: Use image node_id 1 to create a new DenselyConnectedBlock object from inherited base classes: nn with example: obj = DenselyConnectedBlock(in_channels, out_channels, hid_channels, kernel_size, padding, last_kernel_size, last_stride, last_padding, last_output_padding, layers, transposed)