class_docstr: ResBlock adapted from DDPM.
class_docstr_tok: ["ResBlock","adapted","from","DDPM","."]
code: def __init__(
      self,
      act,
      in_ch,
      out_ch=None,
      temb_dim=None,
      conv_shortcut=False,
      dropout=0.1,
      skip_rescale=False,
      init_scale=0.0,
  ):
      super().__init__()
      out_ch = out_ch if out_ch else in_ch
      self.GroupNorm_0 = nn.GroupNorm(
          num_groups=min(in_ch // 4, 32), num_channels=in_ch, eps=1e-6
      )
      self.Conv_0 = conv3x3(in_ch, out_ch)
      if temb_dim is not None:
          self.Dense_0 = nn.Linear(temb_dim, out_ch)
          self.Dense_0.weight.data = default_init()(
              self.Dense_0.weight.data.shape
          )
          nn.init.zeros_(self.Dense_0.bias)
      self.GroupNorm_1 = nn.GroupNorm(
          num_groups=min(out_ch // 4, 32), num_channels=out_ch, eps=1e-6
      )
      self.Dropout_0 = nn.Dropout(dropout)
      self.Conv_1 = conv3x3(out_ch, out_ch, init_scale=init_scale)
      if in_ch != out_ch:
          if conv_shortcut:
              self.Conv_2 = conv3x3(in_ch, out_ch)
          else:
              self.NIN_0 = NIN(in_ch, out_ch)
  
      self.skip_rescale = skip_rescale
      self.act = act
      self.out_ch = out_ch
      self.conv_shortcut = conv_shortcut
  
imports: import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from espnet2.enh.layers.ncsnpp_utils import layers, up_or_down_sampling
label_desc: Use image node_id 1 to create a new ResnetBlockDDPMpp object from inherited base classes: nn with example: obj = ResnetBlockDDPMpp(act, in_ch, out_ch, temb_dim, conv_shortcut, dropout, skip_rescale, init_scale)