code: def __init__(
      self,
      in_channels: int,
      out_channels: int,
      temb_channels: int,
      dropout: float = 0.0,
      num_layers: int = 1,
      transformer_layers_per_block: 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,
      num_attention_heads=1,
      cross_attention_dim=1280,
      output_scale_factor=1.0,
      downsample_padding=1,
      add_downsample=True,
      dual_cross_attention=False,
      use_linear_projection=False,
      only_cross_attention=False,
      upcast_attention=False,
      attention_type="default",
  ):
      super().__init__()
      resnets = []
      attentions = []
  
      self.has_cross_attention = True
      self.num_attention_heads = num_attention_heads
  
      for i in range(num_layers):
          in_channels = in_channels if i == 0 else out_channels
          resnets.append(
              ResnetBlockFlat(
                  in_channels=in_channels,
                  out_channels=out_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,
              )
          )
          if not dual_cross_attention:
              attentions.append(
                  Transformer2DModel(
                      num_attention_heads,
                      out_channels // num_attention_heads,
                      in_channels=out_channels,
                      num_layers=transformer_layers_per_block,
                      cross_attention_dim=cross_attention_dim,
                      norm_num_groups=resnet_groups,
                      use_linear_projection=use_linear_projection,
                      only_cross_attention=only_cross_attention,
                      upcast_attention=upcast_attention,
                      attention_type=attention_type,
                  )
              )
          else:
              attentions.append(
                  DualTransformer2DModel(
                      num_attention_heads,
                      out_channels // num_attention_heads,
                      in_channels=out_channels,
                      num_layers=1,
                      cross_attention_dim=cross_attention_dim,
                      norm_num_groups=resnet_groups,
                  )
              )
      self.attentions = nn.ModuleList(attentions)
      self.resnets = nn.ModuleList(resnets)
  
      if add_downsample:
          self.downsamplers = nn.ModuleList(
              [
                  LinearMultiDim(
                      out_channels,
                      use_conv=True,
                      out_channels=out_channels,
                      padding=downsample_padding,
                      name="op",
                  )
              ]
          )
      else:
          self.downsamplers = None
  
      self.gradient_checkpointing = False
  
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 CrossAttnDownBlockFlat object from inherited base classes: nn with example: obj = CrossAttnDownBlockFlat(in_channels, out_channels, temb_channels, dropout, num_layers, transformer_layers_per_block, resnet_eps, resnet_time_scale_shift, resnet_act_fn, resnet_groups, resnet_pre_norm, num_attention_heads, cross_attention_dim, output_scale_factor, downsample_padding, add_downsample, dual_cross_attention, use_linear_projection, only_cross_attention, upcast_attention, attention_type)