class_docstr: A SubBlock is the largest piece of either base or control model, that is executed independently of the other model respectively.
  Before each subblock, information is concatted from base to control. And after each subblock, information is added from control to base.
class_docstr_tok: ["A","SubBlock","is","the","largest","piece","of","either","base","or","control","model",",","that","is","executed","independently","of","the","other","model","respectively",".","Before","each","subblock",",","information","is","concatted","from","base","to","control",".","And","after","each","subblock",",","information","is","added","from","control","to","base","."]
docstr: Iterate through children and pass correct information to each.
docstr_tok: ["Iterate","through","children","and","pass","correct","information","to","each","."]
code: def forward(
      self,
      x: torch.Tensor,
      temb: torch.Tensor,
      cemb: torch.Tensor,
      attention_mask: Optional[torch.Tensor] = None,
      cross_attention_kwargs: Optional[Dict[str, Any]] = None,
  ):
      """Iterate through children and pass correct information to each."""
      for m in self:
          if isinstance(m, ResnetBlock2D):
              x = m(x, temb)
          elif isinstance(m, Transformer2DModel):
              x = m(
                  x,
                  cemb,
                  attention_mask=attention_mask,
                  cross_attention_kwargs=cross_attention_kwargs,
              ).sample
          elif isinstance(m, Downsample2D):
              x = m(x)
          elif isinstance(m, Upsample2D):
              x = m(x)
          else:
              raise ValueError(
                  f"Type of m is {type(m)} but should be `ResnetBlock2D`, `Transformer2DModel`,  `Downsample2D` or `Upsample2D`"
              )
  
      return x
  
imports: import math
  from dataclasses import dataclass
  from typing import Any, Dict, List, Optional, Tuple, Union
  import torch
  import torch.utils.checkpoint
  from torch import nn
  from torch.nn import functional
  from torch.nn.modules.normalization import GroupNorm
  from diffusers.configuration_utils import ConfigMixin, register_to_config
  from diffusers.models.attention_processor import USE_PEFT_BACKEND, AttentionProcessor
  from diffusers.models.autoencoders import AutoencoderKL
  from diffusers.models.lora import LoRACompatibleConv
  from diffusers.models.modeling_utils import ModelMixin
  from diffusers.models.unet_2d_blocks import CrossAttnDownBlock2D, CrossAttnUpBlock2D, DownBlock2D, Downsample2D, ResnetBlock2D, Transformer2DModel, UpBlock2D, Upsample2D
  from diffusers.models.unet_2d_condition import UNet2DConditionModel
  from diffusers.utils import BaseOutput, logging
label_desc: Use image node_id 2 for calling the SubBlock obj's underlying member method code with example usage: obj.forward(x, temb, cemb, attention_mask, cross_attention_kwargs) and returns: x