class_docstr: Conv2d layer with optimal upsampling and downsampling (StyleGAN2).
class_docstr_tok: ["Conv2d","layer","with","optimal","upsampling","and","downsampling","(","StyleGAN2",")","."]
code: def forward(self, x):
      if self.up:
          x = upsample_conv_2d(x, self.weight, k=self.resample_kernel)
      elif self.down:
          x = conv_downsample_2d(x, self.weight, k=self.resample_kernel)
      else:
          x = F.conv2d(
              x, self.weight, stride=1, padding=self.kernel // 2
          )
  
      if self.use_bias:
          x = x + self.bias.reshape(1, -1, 1, 1)
  
      return x
  
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 2 for calling the Conv2d obj's underlying member method code with example usage: obj.forward(x) and returns: x