code: def __init__(
      self,
      in_channels,
      cat_dim,
      out_channels,
      time_embed_dim,
      context_dim=None,
      num_blocks=3,
      groups=32,
      head_dim=64,
      expansion_ratio=4,
      compression_ratio=2,
      up_sample=True,
      self_attention=True,
  ):
      super().__init__()
      up_resolutions = [
          [None, True if up_sample else None, None, None]
      ] + [[None] * 4] * (num_blocks - 1)
      hidden_channels = (
          [(in_channels + cat_dim, in_channels)]
          + [(in_channels, in_channels)] * (num_blocks - 2)
          + [(in_channels, out_channels)]
      )
      attentions = []
      resnets_in = []
      resnets_out = []
  
      self.self_attention = self_attention
      self.context_dim = context_dim
  
      if self_attention:
          attentions.append(
              Kandinsky3AttentionBlock(
                  out_channels,
                  time_embed_dim,
                  None,
                  groups,
                  head_dim,
                  expansion_ratio,
              )
          )
      else:
          attentions.append(nn.Identity())
  
      for (in_channel, out_channel), up_resolution in zip(
          hidden_channels, up_resolutions
      ):
          resnets_in.append(
              Kandinsky3ResNetBlock(
                  in_channel,
                  in_channel,
                  time_embed_dim,
                  groups,
                  compression_ratio,
                  up_resolution,
              )
          )
  
          if context_dim is not None:
              attentions.append(
                  Kandinsky3AttentionBlock(
                      in_channel,
                      time_embed_dim,
                      context_dim,
                      groups,
                      head_dim,
                      expansion_ratio,
                  )
              )
          else:
              attentions.append(nn.Identity())
  
          resnets_out.append(
              Kandinsky3ResNetBlock(
                  in_channel,
                  out_channel,
                  time_embed_dim,
                  groups,
                  compression_ratio,
              )
          )
  
      self.attentions = nn.ModuleList(attentions)
      self.resnets_in = nn.ModuleList(resnets_in)
      self.resnets_out = nn.ModuleList(resnets_out)
  
imports: from dataclasses import dataclass
  from typing import Dict, Tuple, Union
  import torch
  import torch.utils.checkpoint
  from torch import nn
  from ..configuration_utils import ConfigMixin, register_to_config
  from ..utils import BaseOutput, logging
  from .attention_processor import Attention, AttentionProcessor, AttnProcessor
  from .embeddings import TimestepEmbedding, Timesteps
  from .modeling_utils import ModelMixin
label_desc: Use image node_id 1 to create a new Kandinsky3UpSampleBlock object from inherited base classes: nn with example: obj = Kandinsky3UpSampleBlock(in_channels, cat_dim, out_channels, time_embed_dim, context_dim, num_blocks, groups, head_dim, expansion_ratio, compression_ratio, up_sample, _attention)