class_docstr: An implementation of Block Neural Autoregressive Flow (block-NAF)
  (De Cao et al., 2019) bijective transform. Block-NAF uses a similar
  transformation to deep dense NAF, building the autoregressive NN into the
  structure of the transform, in a sense.
  
  Together with :class:`~pyro.distributions.TransformedDistribution` this provides
  a way to create richer variational approximations.
  
  Example usage:
  
  >>> base_dist = dist.Normal(torch.zeros(10), torch.ones(10))
  >>> naf = BlockAutoregressive(input_dim=10)
  >>> pyro.module("my_naf", naf)  # doctest: +SKIP
  >>> naf_dist = dist.TransformedDistribution(base_dist, [naf])
  >>> naf_dist.sample()  # doctest: +SKIP
  
  The inverse operation is not implemented. This would require numerical
  inversion, e.g., using a root finding method - a possibility for a future
  implementation.
  
  :param input_dim: The dimensionality of the input and output variables.
  :type input_dim: int
  :param hidden_factors: Hidden layer i has hidden_factors[i] hidden units per
      input dimension. This corresponds to both :math:`a` and :math:`b` in De Cao
      et al. (2019). The elements of hidden_factors must be integers.
  :type hidden_factors: list
  :param activation: Activation function to use. One of 'ELU', 'LeakyReLU',
      'sigmoid', or 'tanh'.
  :type activation: string
  :param residual: Type of residual connections to use. Choices are "None",
      "normal" for :math:`\mathbf{y}+f(\mathbf{y})`, and "gated" for
      :math:`\alpha\mathbf{y} + (1 - \alpha\mathbf{y})` for learnable
      parameter :math:`\alpha`.
  :type residual: string
  
  References:
  
  [1] Nicola De Cao, Ivan Titov, Wilker Aziz. Block Neural Autoregressive Flow.
  [arXiv:1904.04676]
class_docstr_tok: ["An","implementation","of","Block","Neural","Autoregressive","Flow","(","block-NAF",")","(","De","Cao","et","al.",",","2019",")","bijective","transform",".","Block-NAF","uses","a","similar","transformation","to","deep","dense","NAF",",","building","the","autoregressive","NN","into","the","structure","of","the","transform",",","in","a","sense",".","Together","with",":","class",":","`","~pyro.distributions.TransformedDistribution","`","this","provides","a","way","to","create","richer","variational","approximations",".","Example","usage",":",">",">",">","base_dist","=","dist.Normal","(","torch.zeros","(","10",")",",","torch.ones","(","10",")",")",">",">",">","naf","=","BlockAutoregressive","(","input_dim=10",")",">",">",">","pyro.module","(","``","my_naf","''",",","naf",")","#","doctest",":","+SKIP",">",">",">","naf_dist","=","dist.TransformedDistribution","(","base_dist",",","[","naf","]",")",">",">",">","naf_dist.sample","(",")","#","doctest",":","+SKIP","The","inverse","operation","is","not","implemented",".","This","would","require","numerical","inversion",",","e.g.",",","using","a","root","finding","method","-","a","possibility","for","a","future","implementation",".",":","param","input_dim",":","The","dimensionality","of","the","input","and","output","variables",".",":","type","input_dim",":","int",":","param","hidden_factors",":","Hidden","layer","i","has","hidden_factors","[","i","]","hidden","units","per","input","dimension",".","This","corresponds","to","both",":","math",":","`","a","`","and",":","math",":","`","b","`","in","De","Cao","et","al",".","(","2019",")",".","The","elements","of","hidden_factors","must","be","integers",".",":","type","hidden_factors",":","list",":","param","activation",":","Activation","function","to","use",".","One","of","'ELU","'",",","'LeakyReLU","'",",","'sigmoid","'",",","or","'tanh","'",".",":","type","activation",":","string",":","param","residual",":","Type","of","residual","connections","to","use",".","Choices","are","``","None","''",",","``","normal","''","for",":","math",":","`","\\mathbf","{","y","}","+f","(","\\mathbf","{","y","}",")","`",",","and","``","gated","''","for",":","math",":","`","\\alpha\\mathbf","{","y","}","+","(","1","-","\\alpha\\mathbf","{","y","}",")","`","for","learnable","parameter",":","math",":","`","\\alpha","`",".",":","type","residual",":","string","References",":","[","1","]","Nicola","De","Cao",",","Ivan","Titov",",","Wilker","Aziz",".","Block","Neural","Autoregressive","Flow",".","[","arXiv:1904.04676","]"]
docstr: Calculates the elementwise determinant of the log jacobian
docstr_tok: ["Calculates","the","elementwise","determinant","of","the","log","jacobian"]
code: def log_abs_det_jacobian(self, x, y):
      """
      Calculates the elementwise determinant of the log jacobian
      """
      x_old, y_old = self._cached_x_y
      if x is not x_old or y is not y_old:
          # This call to the parent class Transform will update the cache
          # as well as calling self._call and recalculating y and log_detJ
          self(x)
  
      return self._cached_logDetJ.sum(-1)
  
imports: import math
  import torch
  import torch.nn
  import torch.nn.functional
  from ..None import constraints
  from ..torch_transform import TransformModule
  from ..util import copy_docs_from
  from .neural_autoregressive import ELUTransform, LeakyReLUTransform, TanhTransform
label_desc: Use image node_id 4 for calling the BlockAutoregressive obj's underlying member method code with example usage: obj.log_abs_det_jacobian(x, y) and returns: self