class_docstr: Variational autoencoder module:
  fully-connected and suited for any input shape and type.
  
  The encoder only computes the latent represenations
  and we have then two possible output heads:
  One for the usual output distribution and one for classification.
  The latter is an extension the conventional VAE and incorporates
  a classifier into the network.
  More details can be found in: https://arxiv.org/abs/1809.10635
class_docstr_tok: ["Variational","autoencoder","module",":","fully-connected","and","suited","for","any","input","shape","and","type",".","The","encoder","only","computes","the","latent","represenations","and","we","have","then","two","possible","output","heads",":","One","for","the","usual","output","distribution","and","one","for","classification",".","The","latter","is","an","extension","the","conventional","VAE","and","incorporates","a","classifier","into","the","network",".","More","details","can","be","found","in",":","https",":","\/\/arxiv.org\/abs\/1809.10635"]
docstr: Generate random samples.
  Output is either a single sample if batch_size=None,
  else it is a batch of samples of size "batch_size".
docstr_tok: ["Generate","random","samples",".","Output","is","either","a","single","sample","if","batch_size=None",",","else","it","is","a","batch","of","samples","of","size","``","batch_size","''","."]
code: def generate(self, batch_size=None):
      """
      Generate random samples.
      Output is either a single sample if batch_size=None,
      else it is a batch of samples of size "batch_size".
      """
      z = (
          torch.randn((batch_size, self.dim)).to(self.device)
          if batch_size
          else torch.randn((1, self.dim)).to(self.device)
      )
      res = self.decoder(z)
      if not batch_size:
          res = res.squeeze(0)
      return res
  
imports: from abc import abstractmethod
  from typing import Union
  from matplotlib import transforms
  import torch
  import torch.nn
  from torchvision import transforms
  from avalanche.models.utils import MLP, Flatten
  from avalanche.models.base_model import BaseModel
label_desc: Use image node_id 3 for calling the MlpVAE obj's underlying member method code with example usage: obj.generate(batch_size) and returns: res