code: def __init__(
      self,
      img_size: int,
      latent_dim: int = 128,
      out_channels: int = 3,
      *,
      start_channels: int = 64,
      latent_resolution: int = 4,
      max_channels: int = 256,
      num_classes: Optional[int] = None,
      noise: bool = False,
      demodulate: bool = False,
      num_upsample: Optional[int] = None,
  ):
      super().__init__()
      self.latent_dim = latent_dim
      target_num_upsample = (
          auto_num_layers(img_size, latent_resolution, None) + 1
      )
      if (
          num_upsample is not None
          and num_upsample != target_num_upsample
      ):
          raise ValueError(
              f"`num_upsample` is provided ({num_upsample}), "
              f"but it should be {target_num_upsample}"
          )
      num_upsample = target_num_upsample
      self._initialize(
          out_channels=out_channels,
          img_size=img_size,
          num_upsample=num_upsample,
          num_classes=num_classes,
          latent_resolution=latent_resolution,
      )
      self.noise = noise
      self.demodulate = demodulate
      self.start_channels = start_channels
  
      mul = 2 ** (num_upsample - 1)
      in_nc = min(max_channels, start_channels * mul)
      num_type = 1 if num_classes is None else num_classes
      resolution = latent_resolution
      self.const = nn.Parameter(
          torch.empty(num_type, in_nc, resolution, resolution)
      )
      init.ones_(self.const.data)
  
      blocks: List[nn.Module] = []
      resolution //= 2
      for i in range(num_upsample):
          has_first_conv = i != 0
          upscale = resolution < img_size
          out_nc = min(max_channels, start_channels * mul)
          activation = Activation.make(
              "leaky_relu_0.2" if upscale else "relu"
          )
          blocks.append(
              DecodeBlock(
                  in_nc,
                  out_nc,
                  self.latent_dim,
                  has_first_conv,
                  self.demodulate,
                  upscale,
                  activation,
                  layer=i,
              )
          )
          resolution *= 2
          in_nc = out_nc
          mul //= 2
  
      self.blocks = nn.ModuleList(blocks)
      self.to_output = ToOutput(in_nc, out_channels, gain=0.03)
  
imports: import math
  import torch
  from typing import *
  from torch import nn
  from torch import Tensor
  from torch.nn import init
  from cftool.types import tensor_dict_type
  from .schema import Decoder1DMixin
  from ....constants import INPUT_KEY
  from ....constants import LABEL_KEY
  from ....constants import LATENT_KEY
  from ....misc.toolkit import auto_num_layers
  from ....modules.blocks import Conv2d
  from ....modules.blocks import Linear
  from ....modules.blocks import GaussianBlur3
  from ....modules.blocks import Activation
  from ....modules.blocks import NormFactory
  from ....modules.blocks import UpsampleConv2d
label_desc: Use image node_id 1 to create a new StyleDecoder object from inherited base classes: nn, Decoder1DMixin with example: obj = StyleDecoder(img_size, latent_dim, out_channels)