class_docstr: Conv2d layer with optimal upsampling and downsampling (StyleGAN2).
class_docstr_tok: ["Conv2d","layer","with","optimal","upsampling","and","downsampling","(","StyleGAN2",")","."]
code: def __init__(
      self,
      in_ch,
      out_ch,
      kernel,
      up=False,
      down=False,
      resample_kernel=(1, 3, 3, 1),
      use_bias=True,
      kernel_init=None,
  ):
      super().__init__()
      assert not (up and down)
      assert kernel >= 1 and kernel % 2 == 1
      self.weight = nn.Parameter(
          torch.zeros(out_ch, in_ch, kernel, kernel)
      )
      if kernel_init is not None:
          self.weight.data = kernel_init(self.weight.data.shape)
      if use_bias:
          self.bias = nn.Parameter(torch.zeros(out_ch))
  
      self.up = up
      self.down = down
      self.resample_kernel = resample_kernel
      self.kernel = kernel
      self.use_bias = use_bias
  
file_path: espnet/espnet2/enh/layers/ncsnpp_utils/up_or_down_sampling.py
imports: import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from espnet2.enh.layers.ncsnpp_utils.upfirdn2d import upfirdn2d
label_desc: Use image node_id 1 to create a new Conv2d object from inherited base classes: nn with example: obj = Conv2d(in_ch, out_ch, kernel, up, down, resample_kernel, use_bias, kernel_init)