code: def __init__(
      self,
      encoder_net: Optional[nn.Module] = None,
      input_layer: Optional[nn.Module] = None,
      shape: Optional[tuple] = None,
      enc_dim: Optional[int] = None,
  ) -> None:
      super().__init__()
      is_enc = isinstance(encoder_net, nn.Module)
      is_enc_dim = isinstance(enc_dim, int)
      if is_enc:
          self.encoder = encoder_net
      elif not is_enc and is_enc_dim:  # set default encoder
          input_dim = np.prod(shape)
          step_dim = int((input_dim - enc_dim) / 3)
          self.encoder = _Encoder(
              input_layer,
              input_dim=input_dim,
              enc_dim=enc_dim,
              step_dim=step_dim,
          )
      elif not is_enc and not is_enc_dim:
          raise ValueError(
              "Need to provide either `enc_dim` or a nn.Module"
              " `encoder_net`."
          )
  
file_path: alibi-detect/alibi_detect/cd/pytorch/preprocess.py
imports: from typing import Callable, Dict, Optional, Type, Union
  import numpy
  import torch
  import torch.nn
  from alibi_detect.utils.pytorch.prediction import predict_batch, predict_batch_transformer
  from alibi_detect.utils._types import TorchDeviceType
label_desc: Use image node_id 1 to create a new UAE object from inherited base classes: nn with example: obj = UAE(encoder_net, input_layer, shape, enc_dim)