code: def __init__(
      self,
      in_channels: int,
      num_downsample: int,
      latent_channels: int = 256,
      *,
      kernel_size: int = 3,
      first_kernel_size: int = 7,
      start_channels: Optional[int] = None,
      num_residual_blocks: int = 0,
      residual_dropout: float = 0.0,
      residual_kwargs: Optional[Dict[str, Any]] = None,
      norm_type: Optional[str] = "batch",
      norm_kwargs: Optional[Dict[str, Any]] = None,
      activation: str = "leaky_relu_0.2",
      padding: str = "same",
  ):
      super().__init__()
      self.in_channels = in_channels
      self.num_downsample = num_downsample
      self.latent_channels = latent_channels
      self.first_kernel_size = first_kernel_size
      if start_channels is None:
          start_channels = int(
              round(latent_channels / (2**num_downsample))
          )
      if start_channels <= 0:
          raise ValueError(
              f"latent_channels ({latent_channels}) is too small "
              f"for num_downsample ({num_downsample})"
          )
      # in conv
      blocks = get_conv_blocks(
          in_channels,
          start_channels,
          first_kernel_size,
          1,
          norm_type=norm_type,
          norm_kwargs=norm_kwargs,
          activation=activation,
          padding=padding,
      )
      # downsample
      downsample_padding = padding
      if padding == "reflection":
          downsample_padding = f"reflection{(kernel_size - 1) // 2}"
      in_nc = start_channels
      for i in range(self.num_downsample):
          is_last = i == self.num_downsample - 1
          i_norm_type = norm_type
          i_activation = activation
          if not is_last:
              out_nc = min(in_nc * 2, latent_channels)
          else:
              out_nc = latent_channels
              if num_residual_blocks == 0:
                  i_norm_type = None
                  i_activation = None  # type: ignore
          blocks.extend(
              get_conv_blocks(
                  in_nc,
                  out_nc,
                  kernel_size,
                  2,
                  norm_type=i_norm_type,
                  activation=i_activation,
                  padding=downsample_padding,
              )
          )
          in_nc = out_nc
      # residual
      for _ in range(num_residual_blocks):
          blocks.append(
              ResidualBlock(
                  latent_channels,
                  residual_dropout,
                  norm_type=norm_type,
                  activation=activation,
                  padding=padding,
                  **(residual_kwargs or {}),
              )
          )
      # construct
      self.encoder = nn.Sequential(*blocks)
  
imports: import torch.nn
  from torch import Tensor
  from typing import Any
  from typing import Dict
  from typing import Optional
  from cftool.array import squeeze
  from .schema import EncoderMixin
  from .schema import Encoder1DMixin
  from ....modules.blocks import get_conv_blocks
  from ....modules.blocks import Linear
  from ....modules.blocks import ResidualBlock
label_desc: Use image node_id 1 to create a new VanillaEncoder object from inherited base classes: nn, EncoderMixin with example: obj = VanillaEncoder(in_channels, num_downsample, latent_channels)