class_docstr: Base class for all image autoencoders that we train, like VQGAN or AutoencoderKL
  (we also restore them explicitly as special cases for legacy reasons).
  Regularizations such as KL or VQ are moved to the regularizer class.
class_docstr_tok: ["Base","class","for","all","image","autoencoders","that","we","train",",","like","VQGAN","or","AutoencoderKL","(","we","also","restore","them","explicitly","as","special","cases","for","legacy","reasons",")",".","Regularizations","such","as","KL","or","VQ","are","moved","to","the","regularizer","class","."]
code: def __init__(
      self,
      *args,
      encoder_config: Dict,
      decoder_config: Dict,
      loss_config: Dict,
      regularizer_config: Dict,
      optimizer_config: Union[Dict, None] = None,
      lr_g_factor: float = 1.0,
      trainable_ae_params: Optional[List[List[str]]] = None,
      ae_optimizer_args: Optional[List[dict]] = None,
      trainable_disc_params: Optional[List[List[str]]] = None,
      disc_optimizer_args: Optional[List[dict]] = None,
      disc_start_iter: int = 0,
      diff_boost_factor: float = 3.0,
      ckpt_engine: Union[None, str, dict] = None,
      ckpt_path: Optional[str] = None,
      additional_decode_keys: Optional[List[str]] = None,
      **kwargs,
  ):
      super().__init__(*args, **kwargs)
      self.automatic_optimization = False  # pytorch lightning
  
      self.encoder: torch.nn.Module = instantiate_from_config(
          encoder_config
      )
      self.decoder: torch.nn.Module = instantiate_from_config(
          decoder_config
      )
      self.loss: torch.nn.Module = instantiate_from_config(loss_config)
      self.regularization: AbstractRegularizer = (
          instantiate_from_config(regularizer_config)
      )
      self.optimizer_config = default(
          optimizer_config, {"target": "torch.optim.Adam"}
      )
      self.diff_boost_factor = diff_boost_factor
      self.disc_start_iter = disc_start_iter
      self.lr_g_factor = lr_g_factor
      self.trainable_ae_params = trainable_ae_params
      if self.trainable_ae_params is not None:
          self.ae_optimizer_args = default(
              ae_optimizer_args,
              [{} for _ in range(len(self.trainable_ae_params))],
          )
          assert len(self.ae_optimizer_args) == len(
              self.trainable_ae_params
          )
      else:
          self.ae_optimizer_args = [{}]  # makes type consitent
  
      self.trainable_disc_params = trainable_disc_params
      if self.trainable_disc_params is not None:
          self.disc_optimizer_args = default(
              disc_optimizer_args,
              [{} for _ in range(len(self.trainable_disc_params))],
          )
          assert len(self.disc_optimizer_args) == len(
              self.trainable_disc_params
          )
      else:
          self.disc_optimizer_args = [{}]  # makes type consitent
  
      if ckpt_path is not None:
          assert (
              ckpt_engine is None
          ), "Can't set ckpt_engine and ckpt_path"
          logpy.warn(
              "Checkpoint path is deprecated, use `checkpoint_egnine` instead"
          )
      self.apply_ckpt(default(ckpt_path, ckpt_engine))
      self.additional_decode_keys = set(
          default(additional_decode_keys, [])
      )
  
imports: import logging
  import math
  import re
  from abc import abstractmethod
  from contextlib import contextmanager
  from typing import Any, Dict, List, Optional, Tuple, Union
  import pytorch_lightning
  import torch
  import torch.nn
  from einops import rearrange
  from packaging import version
  from ..modules.autoencoding.regularizers import AbstractRegularizer
  from ..modules.ema import LitEma
  from ..util import default, get_nested_attribute, get_obj_from_str, instantiate_from_config
label_desc: Use image node_id 1 to create a new AutoencodingEngine object from inherited base classes: AbstractAutoencoder with example: obj = AutoencodingEngine()