class_docstr: A Variational Autoencoder (VAE) implementation.
  
  Paper reference: https://arxiv.org/abs/1312.6114
  
  Arguments
  ---------
  encoder: torch.Module
      the encoder network
  
  decoder: torch.Module
      the decoder network
  
  mean: torch.Module
      the module that computes the mean
  
  log_var: torch.Module
      the module that computes the log variance
  
  mask_value: float
      The value with which outputs and latents will be masked
  
  len_dim: None
      the length dimension
  
  mask_latent: bool
      where to apply the length mask to the latent representation
  
  mask_out: bool
      whether to apply the length mask to the output
  
  out_mask_value: float
      the mask value used for the output
  
  latent_mask_value: float
      the mask value used for the latent representation
  
  latent_stochastic: bool
      if true, the "latent" parameter of VariationalAutoencoderOutput
      will be the latent space sample
  
      if false, it will be the mean
  
  Example
  -------
  The example below shows a very simple implementation of
  VAE, not suitable for actual experiments:
  
  >>> import torch
  >>> from torch import nn
  >>> from speechbrain.nnet.linear import Linear
  >>> vae_enc = Linear(n_neurons=16, input_size=128)
  >>> vae_dec = Linear(n_neurons=128, input_size=16)
  >>> vae_mean = Linear(n_neurons=16, input_size=16)
  >>> vae_log_var = Linear(n_neurons=16, input_size=16)
  >>> vae = VariationalAutoencoder(
  ...     encoder=vae_enc,
  ...     decoder=vae_dec,
  ...     mean=vae_mean,
  ...     log_var=vae_log_var,
  ... )
  >>> x = torch.randn(4, 10, 128)
  
  `train_sample` encodes a single batch and then reconstructs
  it
  
  >>> vae_out = vae.train_sample(x)
  >>> vae_out.rec.shape
  torch.Size([4, 10, 128])
  >>> vae_out.latent.shape
  torch.Size([4, 10, 16])
  >>> vae_out.mean.shape
  torch.Size([4, 10, 16])
  >>> vae_out.log_var.shape
  torch.Size([4, 10, 16])
  >>> vae_out.latent_sample.shape
  torch.Size([4, 10, 16])
  
  .encode() will return the mean corresponding
  to teh sample provided
  
  >>> x_enc = vae.encode(x)
  >>> x_enc.shape
  torch.Size([4, 10, 16])
  
  .reparameterize() performs the reparameterization
  trick
  
  >>> x_enc = vae.encoder(x)
  >>> mean = vae.mean(x_enc)
  >>> log_var = vae.log_var(x_enc)
  >>> x_repar = vae.reparameterize(mean, log_var)
  >>> x_repar.shape
  torch.Size([4, 10, 16])
docstr: Converts a sample from an original space (e.g. pixel or waveform) to a latent
  space
  
  Arguments
  ---------
  x: torch.Tensor
      the original data representation
  
  Returns
  -------
  latent: torch.Tensor
      the latent representation
docstr_tok: ["Converts","a","sample","from","an","original","space","(","e.g",".","pixel","or","waveform",")","to","a","latent","space","Arguments","--","--","--","--","-","x",":","torch.Tensor","the","original","data","representation","Returns","--","--","--","-","latent",":","torch.Tensor","the","latent","representation"]
code: def encode(self, x, length=None):
      """Converts a sample from an original space (e.g. pixel or waveform) to a latent
      space
  
      Arguments
      ---------
      x: torch.Tensor
          the original data representation
  
      Returns
      -------
      latent: torch.Tensor
          the latent representation
      """
      encoder_out = self.encoder(x)
      return self.mean(encoder_out)
  
imports: import torch
  from torch import nn
  from collections import namedtuple
  from speechbrain.dataio.dataio import clean_padding
  from speechbrain.utils.data_utils import trim_as
  from speechbrain.processing.features import GlobalNorm
label_desc: Use image node_id 2 for calling the VariationalAutoencoder obj's underlying member method code with example usage: obj.encode(x, length) and returns: self