class_docstr: Applies a 2D Transpose convolution (aka as Deconvolution) over an input.
  
  Args:
      opts: Command line arguments.
      in_channels: :math:`C_{in}` from an expected input of size
        :math:`(N, C_{in}, H_{in}, W_{in})`.
      out_channels: :math:`C_{out}` from an expected output of size
        :math:`(N, C_{out}, H_{out}, W_{out})`.
      kernel_size: Kernel size for convolution.
      stride: Stride for convolution. Default: 1.
      dilation: Dilation rate for convolution. Default: 1.
      groups: Number of groups in convolution. Default: 1.
      bias: Use bias. Default: ``False``.
      padding_mode: Padding mode. Default: ``zeros``.
      use_norm: Use normalization layer after convolution. Default: ``True``.
      use_act: Use activation layer after convolution (or convolution and normalization).
      Default: ``True``.
      padding: Padding will be done on both sides of each dimension in the input.
      output_padding: Additional padding on the output tensor.
      auto_padding: Compute padding automatically. Default: ``True``.
  
  Shape:
      - Input: :math:`(N, C_{in}, H_{in}, W_{in})`.
      - Output: :math:`(N, C_{out}, H_{out}, W_{out})`.
class_docstr_tok: ["Applies","a","2D","Transpose","convolution","(","aka","as","Deconvolution",")","over","an","input",".","Args",":","opts",":","Command","line","arguments",".","in_channels",":",":","math",":","`","C_","{","in","}","`","from","an","expected","input","of","size",":","math",":","`","(","N",",","C_","{","in","}",",","H_","{","in","}",",","W_","{","in","}",")","`",".","out_channels",":",":","math",":","`","C_","{","out","}","`","from","an","expected","output","of","size",":","math",":","`","(","N",",","C_","{","out","}",",","H_","{","out","}",",","W_","{","out","}",")","`",".","kernel_size",":","Kernel","size","for","convolution",".","stride",":","Stride","for","convolution",".","Default",":","1.","dilation",":","Dilation","rate","for","convolution",".","Default",":","1.","groups",":","Number","of","groups","in","convolution",".","Default",":","1.","bias",":","Use","bias",".","Default",":","``","False","``",".","padding_mode",":","Padding","mode",".","Default",":","``","zeros","``",".","use_norm",":","Use","normalization","layer","after","convolution",".","Default",":","``","True","``",".","use_act",":","Use","activation","layer","after","convolution","(","or","convolution","and","normalization",")",".","Default",":","``","True","``",".","padding",":","Padding","will","be","done","on","both","sides","of","each","dimension","in","the","input",".","output_padding",":","Additional","padding","on","the","output","tensor",".","auto_padding",":","Compute","padding","automatically",".","Default",":","``","True","``",".","Shape",":","-","Input",":",":","math",":","`","(","N",",","C_","{","in","}",",","H_","{","in","}",",","W_","{","in","}",")","`",".","-","Output",":",":","math",":","`","(","N",",","C_","{","out","}",",","H_","{","out","}",",","W_","{","out","}",")","`","."]
code: def __init__(
      self,
      opts: argparse.Namespace,
      in_channels: int,
      out_channels: int,
      kernel_size: Union[int, Tuple],
      stride: Optional[Union[int, Tuple]] = 1,
      dilation: Optional[Union[int, Tuple]] = 1,
      groups: Optional[int] = 1,
      bias: Optional[bool] = False,
      padding_mode: Optional[str] = "zeros",
      use_norm: Optional[bool] = True,
      use_act: Optional[bool] = True,
      padding: Optional[Union[int, Tuple]] = (0, 0),
      output_padding: Optional[Union[int, Tuple]] = None,
      auto_padding: Optional[bool] = True,
      *args,
      **kwargs,
  ):
      super().__init__()
  
      if use_norm:
          assert (
              not bias
          ), "Do not use bias when using normalization layers."
  
      if isinstance(kernel_size, int):
          kernel_size = (kernel_size, kernel_size)
  
      if isinstance(stride, int):
          stride = (stride, stride)
  
      if isinstance(dilation, int):
          dilation = (dilation, dilation)
  
      if output_padding is None:
          output_padding = (stride[0] - 1, stride[1] - 1)
  
      assert isinstance(kernel_size, (tuple, list))
      assert isinstance(stride, (tuple, list))
      assert isinstance(dilation, (tuple, list))
  
      if auto_padding:
          padding = (
              int((kernel_size[0] - 1) / 2) * dilation[0],
              int((kernel_size[1] - 1) / 2) * dilation[1],
          )
  
      if in_channels % groups != 0:
          logger.error(
              "Input channels are not divisible by groups. {}%{} != 0 ".format(
                  in_channels, groups
              )
          )
      if out_channels % groups != 0:
          logger.error(
              "Output channels are not divisible by groups. {}%{} != 0 ".format(
                  out_channels, groups
              )
          )
  
      block = nn.Sequential()
      conv_layer = nn.ConvTranspose2d(
          in_channels=in_channels,
          out_channels=out_channels,
          kernel_size=kernel_size,
          stride=stride,
          padding=padding,
          dilation=dilation,
          groups=groups,
          bias=bias,
          padding_mode=padding_mode,
          output_padding=output_padding,
      )
  
      block.add_module(name="conv", module=conv_layer)
  
      self.norm_name = None
      if use_norm:
          norm_layer = get_normalization_layer(
              opts=opts, num_features=out_channels
          )
          block.add_module(name="norm", module=norm_layer)
          self.norm_name = norm_layer.__class__.__name__
  
      self.act_name = None
      act_type = getattr(opts, "model.activation.name", "relu")
  
      if act_type is not None and use_act:
          act_layer = build_activation_layer(
              opts,
              act_type=act_type,
              num_parameters=out_channels,
          )
          block.add_module(name="act", module=act_layer)
          self.act_name = act_layer.__class__.__name__
  
      self.block = block
  
      self.in_channels = in_channels
      self.out_channels = out_channels
      self.stride = stride
      self.groups = groups
      self.kernel_size = conv_layer.kernel_size
      self.bias = bias
  
imports: import argparse
  from typing import Optional, Tuple, Type, Union
  from torch import Tensor, nn
  from cvnets.layers.activation import build_activation_layer
  from cvnets.layers.base_layer import BaseLayer
  from cvnets.layers.normalization.layer_norm import LayerNorm, LayerNorm2D_NCHW
  from cvnets.layers.normalization_layers import get_normalization_layer
  from utils import logger
label_desc: Use image node_id 1 to create a new TransposeConvLayer2d object from inherited base classes: BaseLayer with example: obj = TransposeConvLayer2d(opts, in_channels, out_channels, kernel_size, stride, dilation, groups, bias, padding_mode, use_norm, use_act, padding, output_padding, auto_padding)