code: def __init__(
      self,
      in_channels: int,
      out_channels: Optional[int] = None,
      *,
      signal_dim: int = 2,
      dropout: float = 0.0,
      norm_eps: float = 1.0e-6,
      use_conv_shortcut: bool = False,
      integrate_upsample: bool = False,
      integrate_downsample: bool = False,
      time_embedding_channels: int = 512,
      use_scale_shift_norm: bool = False,
      use_checkpoint: bool = False,
  ):
      super().__init__()
      self.in_channels = in_channels
      out_channels = out_channels or in_channels
      self.out_channels = out_channels
      self.use_conv_shortcut = use_conv_shortcut
      self.use_scale_shift_norm = use_scale_shift_norm
      self.use_checkpoint = use_checkpoint
  
      self.resample = integrate_upsample or integrate_downsample
      if not self.resample:
          self.inp_resample = self.net_resample = None
      elif integrate_upsample:
          self.inp_resample = ResUpsample(
              in_channels, False, signal_dim=signal_dim
          )
          self.net_resample = ResUpsample(
              in_channels, False, signal_dim=signal_dim
          )
      else:
          self.inp_resample = ResDownsample(
              in_channels, False, signal_dim=signal_dim
          )
          self.net_resample = ResDownsample(
              in_channels, False, signal_dim=signal_dim
          )
  
      make_norm = lambda c: nn.GroupNorm(
          num_groups=32, num_channels=c, eps=norm_eps
      )
  
      self.activation = nn.SiLU()
      self.norm1 = make_norm(in_channels)
      self.conv1 = conv_nd(
          signal_dim, in_channels, out_channels, 3, 1, 1
      )
      if time_embedding_channels > 0:
          if use_scale_shift_norm:
              t_out_channels = 2 * out_channels
          else:
              t_out_channels = out_channels
          self.time_embedding = HijackLinear(
              time_embedding_channels, t_out_channels
          )
      self.norm2 = make_norm(out_channels)
      self.dropout = nn.Dropout(dropout)
      conv2 = conv_nd(signal_dim, out_channels, out_channels, 3, 1, 1)
      self.conv2 = zero_module(conv2)
      if in_channels != out_channels:
          if use_conv_shortcut:
              self.shortcut = HijackConv2d(
                  in_channels, out_channels, 3, 1, 1
              )
          else:
              self.shortcut = HijackConv2d(
                  in_channels, out_channels, 1, 1, 0
              )
  
imports: import torch
  import torch.nn
  import torch.nn.functional
  from torch import Tensor
  from typing import Any
  from typing import Optional
  from torch.nn import Module
  from cftool.misc import shallow_copy_dict
  from .basic import conv_nd
  from .basic import get_conv_blocks
  from ..utils import avg_pool_nd
  from ..utils import zero_module
  from ..utils import Residual
  from ..hijacks import HijackConv2d
  from ..hijacks import HijackLinear
  from ....misc.toolkit import safe_clip_
  from ....misc.toolkit import gradient_checkpoint
label_desc: Use image node_id 1 to create a new ResidualBlockWithTimeEmbedding object from inherited base classes: Module with example: obj = ResidualBlockWithTimeEmbedding(in_channels, out_channels)