class_docstr: MNIST encoder used in the experiments for the Counterfactual with Reinforcement Learning. The model
  consists of 3 convolutional layers having 16, 8 and 8 channels and a kernel size of 3, with ReLU nonlinearities.
  Each convolutional layer is followed by a maxpooling layer of size 2. Finally, a fully connected layer
  follows the convolutional block with a tanh nonlinearity. The tanh clips the output between [-1, 1], required
  in the DDPG algorithm (e.g., [act_low, act_high]). The embedding dimension used in the paper is 32, although
  this can vary.
docstr: Constructor.
  
  Parameters
  ----------
  latent_dim
      Latent dimension.
docstr_tok: ["Constructor",".","Parameters","--","--","--","--","--","latent_dim","Latent","dimension","."]
code: def __init__(self, latent_dim: int):
      """
      Constructor.
  
      Parameters
      ----------
      latent_dim
          Latent dimension.
      """
      super().__init__()
  
      self.conv1 = nn.Conv2d(1, 16, kernel_size=(3, 3), padding=1)
      self.maxpool1 = nn.MaxPool2d((2, 2), stride=2)
      self.conv2 = nn.Conv2d(16, 8, kernel_size=(3, 3), padding=1)
      self.maxpool2 = nn.MaxPool2d((2, 2), stride=2)
      self.conv3 = nn.Conv2d(8, 8, kernel_size=(3, 3), padding=2)
      self.maxpool3 = nn.MaxPool2d((2, 2), stride=2)
      self.flatten = nn.Flatten()
      self.fc1 = nn.Linear(8 * 4 * 4, latent_dim)
  
imports: import torch
  import torch.nn
  import torch.nn.functional
  from typing import List
  from alibi.models.pytorch.model import Model
label_desc: Use image node_id 1 to create a new MNISTEncoder object from inherited base classes: nn with example: obj = MNISTEncoder(latent_dim)