code: def __init__(
      self,
      img_size: int,
      in_channels: int = 3,
      latent_channels: int = 256,
      *,
      channel_multipliers: Optional[List[int]] = None,
      attention_resolutions: Optional[List[int]] = None,
      latent_dim: int = 128,
      res_dropout: float = 0.0,
      num_res_blocks: int = 2,
  ):
      super().__init__()
      if channel_multipliers is None:
          channel_multipliers = [1, 1, 2, 2, 4]
      if attention_resolutions is None:
          attention_resolutions = [16]
      num_downsample = len(channel_multipliers)
      self.in_channels = in_channels
      self.num_downsample = num_downsample
      self.latent_channels = latent_channels
      self.num_res_blocks = num_res_blocks
      # in conv
      blocks = [
          Conv2d(in_channels, latent_dim, kernel_size=3, padding=1)
      ]
      # downsample
      current_res = img_size
      in_channel_multipliers = [1] + channel_multipliers
      in_nc = 0
      for i in range(num_downsample):
          i_blocks = []
          in_nc = latent_dim * in_channel_multipliers[i]
          out_nc = latent_dim * channel_multipliers[i]
          for j in range(num_res_blocks):
              i_blocks.append(
                  ResidualBlock(
                      in_nc,
                      out_nc,
                      dropout=res_dropout,
                  )
              )
              in_nc = out_nc
              if current_res in attention_resolutions:
                  i_blocks.append(AttnBlock(in_nc))
          if i != num_downsample - 1:
              i_blocks.append(Downsample(in_nc))
              current_res //= 2
          blocks.append(nn.Sequential(*i_blocks))
      # mid
      blocks.extend(
          [
              ResidualBlock(in_nc, in_nc, res_dropout),
              AttnBlock(in_nc),
              ResidualBlock(in_nc, in_nc, res_dropout),
          ]
      )
      # finalize
      blocks.extend(
          [
              normalize(in_nc),
              nn.SiLU(),
              Conv2d(in_nc, latent_channels, kernel_size=3, padding=1),
          ]
      )
      self.net = nn.Sequential(*blocks)
  
imports: import torch
  import torch.nn
  from torch import Tensor
  from typing import List
  from typing import Optional
  from .schema import EncoderMixin
  from ....modules.blocks import Conv2d
label_desc: Use image node_id 1 to create a new VQGANEncoder object from inherited base classes: nn, EncoderMixin with example: obj = VQGANEncoder(img_size, in_channels, latent_channels)