code: def __init__(
      self,
      ch: int = 128,
      ch_mult: Optional[Sequence] = None,
      num_res_blocks: int = 2,
      attn_resolutions: Optional[Sequence] = None,
      dropout: float = 0.0,
      resamp_with_conv: bool = True,
      in_channels: int = 3,
      resolution: int = 256,
      embed_dim: int = 256,
      norm_type: str = "group",
  ):
      super().__init__()
      if ch_mult is None:
          ch_mult = (1, 1, 2, 2, 4)
      if attn_resolutions is None:
          attn_resolutions = [16]
  
      self.ch = ch
      self.num_resolutions = len(ch_mult)
      self.num_res_blocks = num_res_blocks
      self.resolution = resolution
      self.in_channels = in_channels
      self.embed_dim = embed_dim
      self.grid_size = attn_resolutions
  
      if norm_type == "channel_last":
          norm_type = "group"
  
      # downsampling
      self.conv_in = torch.nn.Conv2d(
          in_channels, self.ch, kernel_size=3, stride=1, padding=1
      )
  
      curr_res = resolution
      in_ch_mult = (1,) + tuple(ch_mult)
      self.down = nn.ModuleList()
      for i_level in range(self.num_resolutions):
          block = nn.ModuleList()
          attn = nn.ModuleList()
          block_in = ch * in_ch_mult[i_level]
          block_out = ch * ch_mult[i_level]
          for _ in range(self.num_res_blocks):
              block.append(
                  _ResnetBlock(
                      in_channels=block_in,
                      out_channels=block_out,
                      dropout=dropout,
                      norm_type=norm_type,
                  )
              )
              block_in = block_out
              if curr_res in attn_resolutions:
                  attn.append(
                      _AttnBlock(
                          block_in, curr_res, norm_type=norm_type
                      )
                  )
          down = nn.Module()
          down.block = block
          down.attn = attn
          if i_level != self.num_resolutions - 1:
              down.downsample = _Downsample(block_in, resamp_with_conv)
              curr_res = curr_res // 2
          self.down.append(down)
  
      # middle
      self.mid = nn.Sequential(
          _ResnetBlock(
              in_channels=block_in,
              out_channels=block_in,
              dropout=dropout,
              norm_type=norm_type,
          ),
          _AttnBlock(block_in, curr_res, norm_type=norm_type),
          _ResnetBlock(
              in_channels=block_in,
              out_channels=block_in,
              dropout=dropout,
              norm_type=norm_type,
          ),
      )
  
      # end
      self.norm_out = create_norm(block_in, norm_type=norm_type)
      self.conv_out = torch.nn.Conv2d(
          block_in,
          embed_dim,
          kernel_size=3,
          stride=1,
          padding=1,
      )
  
imports: import logging
  from typing import Optional, Sequence
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from torch import Tensor
  from neuralcompression.layers import XCA, ChannelNorm2D
  from .._outputs._vqvae_autoencoder_output import VqVaeAutoencoderOutput
label_desc: Use image node_id 1 to create a new _VqVaeXCiTConvEncoder object from inherited base classes: nn with example: obj = _VqVaeXCiTConvEncoder(ch, ch_mult, num_res_blocks, attn_resolutions, dropout, resamp_with_conv, in_channels, resolution, embed_dim, norm_type)