class_docstr: Masked Autoregressive Flow.
  
  Args:
      model_config (MAFConfig): The MAF model configuration setting the main parameters of the
          model.
class_docstr_tok: ["Masked","Autoregressive","Flow",".","Args",":","model_config","(","MAFConfig",")",":","The","MAF","model","configuration","setting","the","main","parameters","of","the","model","."]
docstr: The input data is transformed toward the prior
  
  Args:
      inputs (torch.Tensor): An input tensor
  
  Returns:
      ModelOutput: An instance of ModelOutput containing all the relevant parameters
docstr_tok: ["The","input","data","is","transformed","toward","the","prior","Args",":","inputs","(","torch.Tensor",")",":","An","input","tensor","Returns",":","ModelOutput",":","An","instance","of","ModelOutput","containing","all","the","relevant","parameters"]
code: def forward(self, x: torch.Tensor, **kwargs) -> ModelOutput:
      """The input data is transformed toward the prior
  
      Args:
          inputs (torch.Tensor): An input tensor
  
      Returns:
          ModelOutput: An instance of ModelOutput containing all the relevant parameters
      """
  
      x = x.reshape(x.shape[0], -1)
      sum_log_abs_det_jac = torch.zeros(x.shape[0]).to(x.device)
  
      for layer in self.net:
          layer_out = layer(x)
          if layer.__class__.__name__ == "MADE":
              mu, log_var = layer_out.mu, layer_out.log_var
  
              x = (x - mu) * (-log_var).exp()
              sum_log_abs_det_jac += -log_var.sum(dim=-1)  # - alpha
  
          else:
              x = layer_out.out
              sum_log_abs_det_jac += layer_out.log_abs_det_jac
  
          x = x.flip(dims=(1,))
  
      return ModelOutput(out=x, log_abs_det_jac=sum_log_abs_det_jac)
  
file_path: benchmark_VAE/src/pythae/models/normalizing_flows/maf/maf_model.py
imports: import os
  import torch
  import torch.nn
  from ...base.base_utils import ModelOutput
  from ..base import BaseNF
  from ..layers import BatchNorm
  from ..made import MADE, MADEConfig
  from .maf_config import MAFConfig
label_desc: Use image node_id 2 for calling the MAF obj's underlying member method code with example usage: obj.forward(x) and returns: ModelOutput