code: def __init__(
      self,
      *,
      in_channels,
      out_channels=None,
      dropout=0.0,
      temb_channels=512,
      groups=32,
      groups_out=None,
      pre_norm=True,
      eps=1e-6,
      time_embedding_norm="default",
      use_in_shortcut=None,
      second_dim=4,
      **kwargs,
  ):
      super().__init__()
      self.pre_norm = pre_norm
      self.pre_norm = True
  
      in_channels = (
          [in_channels, second_dim, 1]
          if isinstance(in_channels, int)
          else list(in_channels)
      )
      self.in_channels_prod = np.array(in_channels).prod()
      self.channels_multidim = in_channels
  
      if out_channels is not None:
          out_channels = (
              [out_channels, second_dim, 1]
              if isinstance(out_channels, int)
              else list(out_channels)
          )
          out_channels_prod = np.array(out_channels).prod()
          self.out_channels_multidim = out_channels
      else:
          out_channels_prod = self.in_channels_prod
          self.out_channels_multidim = self.channels_multidim
      self.time_embedding_norm = time_embedding_norm
  
      if groups_out is None:
          groups_out = groups
  
      self.norm1 = torch.nn.GroupNorm(
          num_groups=groups,
          num_channels=self.in_channels_prod,
          eps=eps,
          affine=True,
      )
      self.conv1 = torch.nn.Conv2d(
          self.in_channels_prod,
          out_channels_prod,
          kernel_size=1,
          padding=0,
      )
  
      if temb_channels is not None:
          self.time_emb_proj = torch.nn.Linear(
              temb_channels, out_channels_prod
          )
      else:
          self.time_emb_proj = None
  
      self.norm2 = torch.nn.GroupNorm(
          num_groups=groups_out,
          num_channels=out_channels_prod,
          eps=eps,
          affine=True,
      )
      self.dropout = torch.nn.Dropout(dropout)
      self.conv2 = torch.nn.Conv2d(
          out_channels_prod, out_channels_prod, kernel_size=1, padding=0
      )
  
      self.nonlinearity = nn.SiLU()
  
      self.use_in_shortcut = (
          self.in_channels_prod != out_channels_prod
          if use_in_shortcut is None
          else use_in_shortcut
      )
  
      self.conv_shortcut = None
      if self.use_in_shortcut:
          self.conv_shortcut = torch.nn.Conv2d(
              self.in_channels_prod,
              out_channels_prod,
              kernel_size=1,
              stride=1,
              padding=0,
          )
  
imports: from typing import Any, Dict, List, Optional, Tuple, Union
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from ...configuration_utils import ConfigMixin, register_to_config
  from ...models import ModelMixin
  from ...models.activations import get_activation
  from ...models.attention import Attention
  from ...models.attention_processor import ADDED_KV_ATTENTION_PROCESSORS, CROSS_ATTENTION_PROCESSORS, AttentionProcessor, AttnAddedKVProcessor, AttnAddedKVProcessor2_0, AttnProcessor
  from ...models.dual_transformer_2d import DualTransformer2DModel
  from ...models.embeddings import GaussianFourierProjection, ImageHintTimeEmbedding, ImageProjection, ImageTimeEmbedding, TextImageProjection, TextImageTimeEmbedding, TextTimeEmbedding, TimestepEmbedding, Timesteps
  from ...models.transformer_2d import Transformer2DModel
  from ...models.unet_2d_condition import UNet2DConditionOutput
  from ...utils import USE_PEFT_BACKEND, is_torch_version, logging, scale_lora_layers, unscale_lora_layers
  from ...utils.torch_utils import apply_freeu
label_desc: Use image node_id 1 to create a new ResnetBlockFlat object from inherited base classes: nn with example: obj = ResnetBlockFlat()