code: def __init__(
      self,
      in_channels: int,
      temb_channels: int,
      dropout: float = 0.0,
      num_layers: int = 1,
      resnet_eps: float = 1e-6,
      resnet_time_scale_shift: str = "default",
      resnet_act_fn: str = "swish",
      resnet_groups: int = 32,
      resnet_pre_norm: bool = True,
      attention_head_dim=1,
      output_scale_factor=1.0,
      cross_attention_dim=1280,
      skip_time_act=False,
      only_cross_attention=False,
      cross_attention_norm=None,
  ):
      super().__init__()
  
      self.has_cross_attention = True
  
      self.attention_head_dim = attention_head_dim
      resnet_groups = (
          resnet_groups
          if resnet_groups is not None
          else min(in_channels // 4, 32)
      )
  
      self.num_heads = in_channels // self.attention_head_dim
  
      # there is always at least one resnet
      resnets = [
          ResnetBlockFlat(
              in_channels=in_channels,
              out_channels=in_channels,
              temb_channels=temb_channels,
              eps=resnet_eps,
              groups=resnet_groups,
              dropout=dropout,
              time_embedding_norm=resnet_time_scale_shift,
              non_linearity=resnet_act_fn,
              output_scale_factor=output_scale_factor,
              pre_norm=resnet_pre_norm,
              skip_time_act=skip_time_act,
          )
      ]
      attentions = []
  
      for _ in range(num_layers):
          processor = (
              AttnAddedKVProcessor2_0()
              if hasattr(F, "scaled_dot_product_attention")
              else AttnAddedKVProcessor()
          )
  
          attentions.append(
              Attention(
                  query_dim=in_channels,
                  cross_attention_dim=in_channels,
                  heads=self.num_heads,
                  dim_head=self.attention_head_dim,
                  added_kv_proj_dim=cross_attention_dim,
                  norm_num_groups=resnet_groups,
                  bias=True,
                  upcast_softmax=True,
                  only_cross_attention=only_cross_attention,
                  cross_attention_norm=cross_attention_norm,
                  processor=processor,
              )
          )
          resnets.append(
              ResnetBlockFlat(
                  in_channels=in_channels,
                  out_channels=in_channels,
                  temb_channels=temb_channels,
                  eps=resnet_eps,
                  groups=resnet_groups,
                  dropout=dropout,
                  time_embedding_norm=resnet_time_scale_shift,
                  non_linearity=resnet_act_fn,
                  output_scale_factor=output_scale_factor,
                  pre_norm=resnet_pre_norm,
                  skip_time_act=skip_time_act,
              )
          )
  
      self.attentions = nn.ModuleList(attentions)
      self.resnets = nn.ModuleList(resnets)
  
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 UNetMidBlockFlatSimpleCrossAttn object from inherited base classes: nn with example: obj = UNetMidBlockFlatSimpleCrossAttn(in_channels, temb_channels, dropout, num_layers, resnet_eps, resnet_time_scale_shift, resnet_act_fn, resnet_groups, resnet_pre_norm, attention_head_dim, output_scale_factor, cross_attention_dim, skip_time_act, only_cross_attention, cross_attention_norm)