code: def __init__(
      self,
      *,
      in_channels,
      out_channels=None,
      conv_shortcut=False,
      dropout=0.0,
      temb_channels=512,
      groups=32,
      groups_out=None,
      pre_norm=True,
      eps=1e-6,
      non_linearity="swish",
      time_embedding_norm="default",
      kernel=None,
      output_scale_factor=1.0,
      use_nin_shortcut=None,
      up=False,
      down=False,
  ):
      super().__init__()
      self.pre_norm = pre_norm
      self.pre_norm = True
      self.in_channels = in_channels
      out_channels = (
          in_channels if out_channels is None else out_channels
      )
      self.out_channels = out_channels
      self.use_conv_shortcut = conv_shortcut
      self.time_embedding_norm = time_embedding_norm
      self.up = up
      self.down = down
      self.output_scale_factor = output_scale_factor
  
      if groups_out is None:
          groups_out = groups
  
      self.norm1 = nn.GroupNorm(
          num_groups=groups, num_channels=in_channels, epsilon=eps
      )
  
      self.conv1 = nn.Conv2D(
          in_channels, out_channels, kernel_size=3, stride=1, padding=1
      )
  
      if temb_channels is not None:
          self.time_emb_proj = nn.Linear(temb_channels, out_channels)
      else:
          self.time_emb_proj = None
  
      self.norm2 = nn.GroupNorm(
          num_groups=groups_out, num_channels=out_channels, epsilon=eps
      )
      self.dropout = nn.Dropout(dropout)
      self.conv2 = nn.Conv2D(
          out_channels, out_channels, kernel_size=3, stride=1, padding=1
      )
  
      if non_linearity == "swish":
          self.nonlinearity = lambda x: F.silu(x)
      elif non_linearity == "mish":
          self.nonlinearity = Mish()
      elif non_linearity == "silu":
          self.nonlinearity = nn.Silu()
  
      self.upsample = self.downsample = None
      if self.up:
          if kernel == "fir":
              fir_kernel = (1, 3, 3, 1)
              self.upsample = lambda x: upsample_2d(x, k=fir_kernel)
          elif kernel == "sde_vp":
              self.upsample = partial(
                  F.interpolate, scale_factor=2.0, mode="nearest"
              )
          else:
              self.upsample = Upsample2D(in_channels, use_conv=False)
      elif self.down:
          if kernel == "fir":
              fir_kernel = (1, 3, 3, 1)
              self.downsample = lambda x: downsample_2d(x, k=fir_kernel)
          elif kernel == "sde_vp":
              self.downsample = partial(
                  F.avg_pool2d, kernel_size=2, stride=2
              )
          else:
              self.downsample = Downsample2D(
                  in_channels, use_conv=False, padding=1, name="op"
              )
  
      self.use_nin_shortcut = (
          self.in_channels != self.out_channels
          if use_nin_shortcut is None
          else use_nin_shortcut
      )
  
      self.conv_shortcut = None
      if self.use_nin_shortcut:
          self.conv_shortcut = nn.Conv2D(
              in_channels,
              out_channels,
              kernel_size=1,
              stride=1,
              padding=0,
          )
  
imports: from functools import partial
  import numpy
  import paddle
  import paddle.nn
  import paddle.nn.functional
label_desc: Use image node_id 1 to create a new ResnetBlock object from inherited base classes: nn with example: obj = ResnetBlock()