class_docstr: An implementation of a MADE-like auto-regressive neural network that can input an additional context variable.
  (See Reference [2] Section 3.3 for an explanation of how the conditional MADE architecture works.)
  
  Example usage:
  
  >>> x = torch.randn(100, 10)
  >>> y = torch.randn(100, 5)
  >>> arn = ConditionalAutoRegressiveNN(10, 5, [50], param_dims=[1])
  >>> p = arn(x, context=y)  # 1 parameters of size (100, 10)
  >>> arn = ConditionalAutoRegressiveNN(10, 5, [50], param_dims=[1, 1])
  >>> m, s = arn(x, context=y) # 2 parameters of size (100, 10)
  >>> arn = ConditionalAutoRegressiveNN(10, 5, [50], param_dims=[1, 5, 3])
  >>> a, b, c = arn(x, context=y) # 3 parameters of sizes, (100, 1, 10), (100, 5, 10), (100, 3, 10)
  
  :param input_dim: the dimensionality of the input variable
  :type input_dim: int
  :param context_dim: the dimensionality of the context variable
  :type context_dim: int
  :param hidden_dims: the dimensionality of the hidden units per layer
  :type hidden_dims: list[int]
  :param param_dims: shape the output into parameters of dimension (p_n, input_dim) for p_n in param_dims
      when p_n > 1 and dimension (input_dim) when p_n == 1. The default is [1, 1], i.e. output two parameters
      of dimension (input_dim), which is useful for inverse autoregressive flow.
  :type param_dims: list[int]
  :param permutation: an optional permutation that is applied to the inputs and controls the order of the
      autoregressive factorization. in particular for the identity permutation the autoregressive structure
      is such that the Jacobian is upper triangular. By default this is chosen at random.
  :type permutation: torch.LongTensor
  :param skip_connections: Whether to add skip connections from the input to the output.
  :type skip_connections: bool
  :param nonlinearity: The nonlinearity to use in the feedforward network such as torch.nn.ReLU(). Note that no
      nonlinearity is applied to the final network output, so the output is an unbounded real number.
  :type nonlinearity: torch.nn.module
  
  Reference:
  
  1. MADE: Masked Autoencoder for Distribution Estimation [arXiv:1502.03509]
  Mathieu Germain, Karol Gregor, Iain Murray, Hugo Larochelle
  
  2. Inference Networks for Sequential Monte Carlo in Graphical Models [arXiv:1602.06701]
  Brooks Paige, Frank Wood
class_docstr_tok: ["An","implementation","of","a","MADE-like","auto-regressive","neural","network","that","can","input","an","additional","context","variable",".","(","See","Reference","[","2","]","Section","3.3","for","an","explanation","of","how","the","conditional","MADE","architecture","works",".",")","Example","usage",":",">",">",">","x","=","torch.randn","(","100",",","10",")",">",">",">","y","=","torch.randn","(","100",",","5",")",">",">",">","arn","=","ConditionalAutoRegressiveNN","(","10",",","5",",","[","50","]",",","param_dims=","[","1","]",")",">",">",">","p","=","arn","(","x",",","context=y",")","#","1","parameters","of","size","(","100",",","10",")",">",">",">","arn","=","ConditionalAutoRegressiveNN","(","10",",","5",",","[","50","]",",","param_dims=","[","1",",","1","]",")",">",">",">","m",",","s","=","arn","(","x",",","context=y",")","#","2","parameters","of","size","(","100",",","10",")",">",">",">","arn","=","ConditionalAutoRegressiveNN","(","10",",","5",",","[","50","]",",","param_dims=","[","1",",","5",",","3","]",")",">",">",">","a",",","b",",","c","=","arn","(","x",",","context=y",")","#","3","parameters","of","sizes",",","(","100",",","1",",","10",")",",","(","100",",","5",",","10",")",",","(","100",",","3",",","10",")",":","param","input_dim",":","the","dimensionality","of","the","input","variable",":","type","input_dim",":","int",":","param","context_dim",":","the","dimensionality","of","the","context","variable",":","type","context_dim",":","int",":","param","hidden_dims",":","the","dimensionality","of","the","hidden","units","per","layer",":","type","hidden_dims",":","list","[","int","]",":","param","param_dims",":","shape","the","output","into","parameters","of","dimension","(","p_n",",","input_dim",")","for","p_n","in","param_dims","when","p_n",">","1","and","dimension","(","input_dim",")","when","p_n","==","1",".","The","default","is","[","1",",","1","]",",","i.e",".","output","two","parameters","of","dimension","(","input_dim",")",",","which","is","useful","for","inverse","autoregressive","flow",".",":","type","param_dims",":","list","[","int","]",":","param","permutation",":","an","optional","permutation","that","is","applied","to","the","inputs","and","controls","the","order","of","the","autoregressive","factorization",".","in","particular","for","the","identity","permutation","the","autoregressive","structure","is","such","that","the","Jacobian","is","upper","triangular",".","By","default","this","is","chosen","at","random",".",":","type","permutation",":","torch.LongTensor",":","param","skip_connections",":","Whether","to","add","skip","connections","from","the","input","to","the","output",".",":","type","skip_connections",":","bool",":","param","nonlinearity",":","The","nonlinearity","to","use","in","the","feedforward","network","such","as","torch.nn.ReLU","(",")",".","Note","that","no","nonlinearity","is","applied","to","the","final","network","output",",","so","the","output","is","an","unbounded","real","number",".",":","type","nonlinearity",":","torch.nn.module","Reference",":","1",".","MADE",":","Masked","Autoencoder","for","Distribution","Estimation","[","arXiv:1502.03509","]","Mathieu","Germain",",","Karol","Gregor",",","Iain","Murray",",","Hugo","Larochelle","2",".","Inference","Networks","for","Sequential","Monte","Carlo","in","Graphical","Models","[","arXiv:1602.06701","]","Brooks","Paige",",","Frank","Wood"]
code: def _forward(self, x):
      h = x
      for layer in self.layers[:-1]:
          h = self.f(layer(h))
      h = self.layers[-1](h)
  
      if self.skip_layer is not None:
          h = h + self.skip_layer(x)
  
      # Shape the output, squeezing the parameter dimension if all ones
      if self.output_multiplier == 1:
          return h
      else:
          h = h.reshape(
              list(x.size()[:-1])
              + [self.output_multiplier, self.input_dim]
          )
  
          # Squeeze dimension if all parameters are one dimensional
          if self.count_params == 1:
              return h
  
          elif self.all_ones:
              return torch.unbind(h, dim=-2)
  
          # If not all ones, then probably don't want to squeeze a single dimension parameter
          else:
              return tuple([h[..., s, :] for s in self.param_slices])
  
imports: import warnings
  import torch
  import torch.nn
  from torch.nn import functional
label_desc: Use image node_id 4 for calling the ConditionalAutoRegressiveNN obj's underlying member method code with example usage: obj._forward(x) and returns: h, h, torch, tuple