class_docstr: Fits an Inverse Autoregressive Flow in the Autoencoder's latent space.
  
  Args:
      model (BaseAE): The AE model to sample from
      sampler_config (IAFSamplerConfig): A IAFSamplerConfig instance containing
          the main parameters of the sampler. If None, a pre-defined configuration is used.
          Default: None
  
  .. note::
  
      The method :class:`~pythae.samplers.IAFSampler.fit` must be called to fit the
      sampler before sampling.
class_docstr_tok: ["Fits","an","Inverse","Autoregressive","Flow","in","the","Autoencoder","'s","latent","space",".","Args",":","model","(","BaseAE",")",":","The","AE","model","to","sample","from","sampler_config","(","IAFSamplerConfig",")",":","A","IAFSamplerConfig","instance","containing","the","main","parameters","of","the","sampler",".","If","None",",","a","pre-defined","configuration","is","used",".","Default",":","None","..","note",":",":","The","method",":","class",":","`","~pythae.samplers.IAFSampler.fit","`","must","be","called","to","fit","the","sampler","before","sampling","."]
code: def __init__(
      self, model: BaseAE, sampler_config: IAFSamplerConfig = None
  ):
      self.is_fitted = False
  
      if sampler_config is None:
          sampler_config = IAFSamplerConfig()
  
      BaseSampler.__init__(
          self, model=model, sampler_config=sampler_config
      )
  
      self.prior = MultivariateNormal(
          torch.zeros(model.model_config.latent_dim).to(self.device),
          torch.eye(model.model_config.latent_dim).to(self.device),
      )
  
      iaf_config = IAFConfig(
          input_dim=(model.model_config.latent_dim,),
          n_made_blocks=sampler_config.n_made_blocks,
          n_hidden_in_made=sampler_config.n_hidden_in_made,
          hidden_size=sampler_config.hidden_size,
          include_batch_norm=sampler_config.include_batch_norm,
      )
  
      iaf_model = IAF(model_config=iaf_config)
  
      self.flow_contained_model = NFModel(self.prior, iaf_model)
  
      self.flow_contained_model.to(self.device)
  
file_path: benchmark_VAE/src/pythae/samplers/iaf_sampler/iaf_sampler.py
imports: import os
  import shutil
  from typing import Union
  import numpy
  import torch
  from torch.distributions import MultivariateNormal
  from torch.utils.data import DataLoader, Dataset
  from ...data.datasets import collate_dataset_output
  from ...data.preprocessors import DataProcessor
  from ...models import BaseAE
  from ...models.normalizing_flows import IAF, IAFConfig, NFModel
  from ...trainers import BaseTrainer, BaseTrainerConfig
  from ..base.base_sampler import BaseSampler
  from .iaf_sampler_config import IAFSamplerConfig
label_desc: Use image node_id 1 to create a new IAFSampler object from inherited base classes: BaseSampler with example: obj = IAFSampler(model, sampler_config)