code: def __init__(
      self, nf, emb_dim, ch_mult, res_blocks, img_size, attn_resolutions
  ):
      super().__init__()
      self.nf = nf
      self.ch_mult = ch_mult
      self.num_resolutions = len(self.ch_mult)
      self.num_res_blocks = res_blocks
      self.resolution = img_size
      self.attn_resolutions = attn_resolutions
      self.in_channels = emb_dim
      self.out_channels = 3
      block_in_ch = self.nf * self.ch_mult[-1]
      curr_res = self.resolution // 2 ** (self.num_resolutions - 1)
  
      blocks = []
      # initial conv
      blocks.append(
          nn.Conv2d(
              self.in_channels,
              block_in_ch,
              kernel_size=3,
              stride=1,
              padding=1,
          )
      )
  
      # non-local attention block
      blocks.append(ResBlock(block_in_ch, block_in_ch))
      blocks.append(AttnBlock(block_in_ch))
      blocks.append(ResBlock(block_in_ch, block_in_ch))
  
      for i in reversed(range(self.num_resolutions)):
          block_out_ch = self.nf * self.ch_mult[i]
  
          for _ in range(self.num_res_blocks):
              blocks.append(ResBlock(block_in_ch, block_out_ch))
              block_in_ch = block_out_ch
  
              if curr_res in self.attn_resolutions:
                  blocks.append(AttnBlock(block_in_ch))
  
          if i != 0:
              blocks.append(Upsample(block_in_ch))
              curr_res = curr_res * 2
  
      blocks.append(normalize(block_in_ch))
      blocks.append(
          nn.Conv2d(
              block_in_ch,
              self.out_channels,
              kernel_size=3,
              stride=1,
              padding=1,
          )
      )
  
      self.blocks = nn.ModuleList(blocks)
  
imports: import torch
  import torch.nn
  import torch.nn.functional
  from basicsr.utils import get_root_logger
  from basicsr.utils.registry import ARCH_REGISTRY
label_desc: Use image node_id 1 to create a new Generator object from inherited base classes: nn with example: obj = Generator(nf, emb_dim, ch_mult, res_blocks, img_size, attn_resolutions)