code: def __init__(
      self,
      *,
      img_size: int,
      patch_size: int,
      in_channels: int,
      latent_dim: int = 128,
      to_patches_type: str = "vanilla",
      to_patches_config: Optional[Dict[str, Any]] = None,
  ):
      nn.Module.__init__(self)
      EncoderFromPatchesMixin.__init__(
          self,
          img_size=img_size,
          patch_size=patch_size,
          in_channels=in_channels,
          latent_dim=latent_dim,
          to_patches_type=to_patches_type,
          to_patches_config=to_patches_config,
      )
      self.in_channels = in_channels
      self.latent_dim = latent_dim
  
imports: import torch
  import torch.nn
  from torch import Tensor
  from typing import Any
  from typing import Dict
  from typing import Type
  from typing import Optional
  from cftool.misc import safe_execute
  from cftool.misc import check_requires
  from cftool.misc import WithRegister
  from cftool.types import tensor_dict_type
  from ....schema import _forward
  from ....schema import TrainerState
  from ....constants import INPUT_KEY
  from ....constants import LATENT_KEY
  from ....misc.toolkit import eval_context
  from ....misc.toolkit import get_device
  from ....modules.blocks import ImgToPatches
label_desc: Use image node_id 1 to create a new Encoder1DFromPatches object from inherited base classes: EncoderFromPatchesMixin, Encoder1DMixin, nn with example: obj = Encoder1DFromPatches()