class_docstr: :math:`\mathcal{S}`-VAE model.
  
  Args:
      model_config (SVAEConfig): The Variational Autoencoder configuration setting the main
      parameters of the model.
  
      encoder (BaseEncoder): An instance of BaseEncoder (inheriting from `torch.nn.Module` which
          plays the role of encoder. This argument allows you to use your own neural networks
          architectures if desired. If None is provided, a simple Multi Layer Preception
          (https://en.wikipedia.org/wiki/Multilayer_perceptron) is used. Default: None.
  
      decoder (BaseDecoder): An instance of BaseDecoder (inheriting from `torch.nn.Module` which
          plays the role of decoder. This argument allows you to use your own neural networks
          architectures if desired. If None is provided, a simple Multi Layer Preception
          (https://en.wikipedia.org/wiki/Multilayer_perceptron) is used. Default: None.
  
  .. note::
      For high dimensional data we advice you to provide you own network architectures. With the
      provided MLP you may end up with a ``MemoryError``.
docstr: Function computed the estimate negative log-likelihood of the model. It uses importance
  sampling method with the approximate posterior distribution. This may take a while.
  
  Args:
      data (torch.Tensor): The input data from which the log-likelihood should be estimated.
          Data must be of shape [Batch x n_channels x ...]
      n_samples (int): The number of importance samples to use for estimation
      batch_size (int): The batchsize to use to avoid memory issues
docstr_tok: ["Function","computed","the","estimate","negative","log-likelihood","of","the","model",".","It","uses","importance","sampling","method","with","the","approximate","posterior","distribution",".","This","may","take","a","while",".","Args",":","data","(","torch.Tensor",")",":","The","input","data","from","which","the","log-likelihood","should","be","estimated",".","Data","must","be","of","shape","[","Batch","x","n_channels","x","...","]","n_samples","(","int",")",":","The","number","of","importance","samples","to","use","for","estimation","batch_size","(","int",")",":","The","batchsize","to","use","to","avoid","memory","issues"]
code: def get_nll(self, data, n_samples=1, batch_size=100):
      """
      Function computed the estimate negative log-likelihood of the model. It uses importance
      sampling method with the approximate posterior distribution. This may take a while.
  
      Args:
          data (torch.Tensor): The input data from which the log-likelihood should be estimated.
              Data must be of shape [Batch x n_channels x ...]
          n_samples (int): The number of importance samples to use for estimation
          batch_size (int): The batchsize to use to avoid memory issues
      """
  
      if n_samples <= batch_size:
          n_full_batch = 1
      else:
          n_full_batch = n_samples // batch_size
          n_samples = batch_size
  
      log_p = []
  
      for i in range(len(data)):
          x = data[i].unsqueeze(0)
  
          log_p_x = []
  
          for j in range(n_full_batch):
              x_rep = torch.cat(batch_size * [x])
  
              encoder_output = self.encoder(x_rep)
              loc, log_concentration = (
                  encoder_output.embedding,
                  encoder_output.log_concentration,
              )
  
              # normalize mean
              loc = loc / loc.norm(dim=-1, keepdim=True)
  
              concentration = torch.nn.functional.softplus(
                  log_concentration
              )
              z = self._sample_von_mises(loc, concentration)
              recon_x = self.decoder(z)["reconstruction"]
              m = loc.shape[-1]
  
              term1 = concentration * (loc * z).sum(
                  dim=-1, keepdim=True
              )
              term2 = (
                  (m / 2 - 1) * concentration.log()
                  - torch.tensor([2 * np.pi])
                  .to(concentration.device)
                  .log()
                  * (m / 2)
                  - (ive(m / 2 - 1, concentration)).log()
                  - concentration
              )
  
              log_q_z_given_x = (term1 + term2).reshape(
                  -1
              )  # VMF log-density
  
              log_p_z = -torch.ones_like(log_q_z_given_x) * (
                  -torch.lgamma(
                      torch.tensor([m / 2]).to(concentration.device)
                  )
                  + torch.tensor([2]).to(concentration.device).log()
                  + torch.tensor([np.pi]).to(concentration.device).log()
                  * (m / 2)
              )
  
              recon_x = self.decoder(z)["reconstruction"]
  
              if self.model_config.reconstruction_loss == "mse":
                  log_p_x_given_z = -0.5 * F.mse_loss(
                      recon_x.reshape(x_rep.shape[0], -1),
                      x_rep.reshape(x_rep.shape[0], -1),
                      reduction="none",
                  ).sum(dim=-1) - torch.tensor(
                      [np.prod(self.input_dim) / 2 * np.log(np.pi * 2)]
                  ).to(
                      data.device
                  )  # decoding distribution is assumed unit variance  N(mu, I)
  
              elif self.model_config.reconstruction_loss == "bce":
                  log_p_x_given_z = -F.binary_cross_entropy(
                      recon_x.reshape(x_rep.shape[0], -1),
                      x_rep.reshape(x_rep.shape[0], -1),
                      reduction="none",
                  ).sum(dim=-1)
  
              log_p_x.append(
                  log_p_x_given_z + log_p_z - log_q_z_given_x
              )  # log(2*pi) simplifies
  
          log_p_x = torch.cat(log_p_x)
  
          log_p.append(
              (
                  torch.logsumexp(log_p_x, 0) - np.log(len(log_p_x))
              ).item()
          )
  
          if i % 100 == 0:
              print(f"Current nll at {i}: {np.mean(log_p)}")
  
      return np.mean(log_p)
  
imports: from typing import Optional
  import numpy
  import torch
  import torch.distributions
  import torch.nn.functional
  from ...data.datasets import BaseDataset
  from ..base.base_utils import ModelOutput
  from ..nn import BaseDecoder, BaseEncoder
  from ..nn.default_architectures import Encoder_SVAE_MLP
  from ..vae import VAE
  from .svae_config import SVAEConfig
  from .svae_utils import ive
label_desc: Use image node_id 8 for calling the SVAE obj's underlying member method code with example usage: obj.get_nll(data, n_samples, batch_size) and returns: np