code: def __init__(
      self,
      in_channels,
      nf,
      emb_dim,
      ch_mult,
      num_res_blocks,
      resolution,
      attn_resolutions,
  ):
      super().__init__()
      self.nf = nf
      self.num_resolutions = len(ch_mult)
      self.num_res_blocks = num_res_blocks
      self.resolution = resolution
      self.attn_resolutions = attn_resolutions
  
      curr_res = self.resolution
      in_ch_mult = (1,) + tuple(ch_mult)
  
      blocks = []
      # initial convultion
      blocks.append(
          nn.Conv2d(in_channels, nf, kernel_size=3, stride=1, padding=1)
      )
  
      # residual and downsampling blocks, with attention on smaller res (16x16)
      for i in range(self.num_resolutions):
          block_in_ch = nf * in_ch_mult[i]
          block_out_ch = nf * 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 attn_resolutions:
                  blocks.append(AttnBlock(block_in_ch))
  
          if i != self.num_resolutions - 1:
              blocks.append(Downsample(block_in_ch))
              curr_res = curr_res // 2
  
      # 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))
  
      # normalise and convert to latent size
      blocks.append(normalize(block_in_ch))
      blocks.append(
          nn.Conv2d(
              block_in_ch, emb_dim, 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 Encoder object from inherited base classes: nn with example: obj = Encoder(in_channels, nf, emb_dim, ch_mult, num_res_blocks, resolution, attn_resolutions)