class_docstr: A type of batch normalization that can be used to stabilize training in
  normalizing flows. The inverse operation is defined as
  
      :math:`x = (y - \hat{\mu}) \oslash \sqrt{\hat{\sigma^2}} \otimes \gamma + \beta`
  
  that is, the standard batch norm equation, where :math:`x` is the input,
  :math:`y` is the output, :math:`\gamma,\beta` are learnable parameters, and
  :math:`\hat{\mu}`/:math:`\hat{\sigma^2}` are smoothed running averages of
  the sample mean and variance, respectively. The constraint :math:`\gamma>0` is
  enforced to ease calculation of the log-det-Jacobian term.
  
  This is an element-wise transform, and when applied to a vector, learns two
  parameters (:math:`\gamma,\beta`) for each dimension of the input.
  
  When the module is set to training mode, the moving averages of the sample mean
  and variance are updated every time the inverse operator is called, e.g., when a
  normalizing flow scores a minibatch with the `log_prob` method.
  
  Also, when the module is set to training mode, the sample mean and variance on
  the current minibatch are used in place of the smoothed averages,
  :math:`\hat{\mu}` and :math:`\hat{\sigma^2}`, for the inverse operator. For
  this reason it is not the case that :math:`x=g(g^{-1}(x))` during training,
  i.e., that the inverse operation is the inverse of the forward one.
  
  Example usage:
  
  >>> from pyro.nn import AutoRegressiveNN
  >>> from pyro.distributions.transforms import AffineAutoregressive
  >>> base_dist = dist.Normal(torch.zeros(10), torch.ones(10))
  >>> iafs = [AffineAutoregressive(AutoRegressiveNN(10, [40])) for _ in range(2)]
  >>> bn = BatchNorm(10)
  >>> flow_dist = dist.TransformedDistribution(base_dist, [iafs[0], bn, iafs[1]])
  >>> flow_dist.sample()  # doctest: +SKIP
  
  :param input_dim: the dimension of the input
  :type input_dim: int
  :param momentum: momentum parameter for updating moving averages
  :type momentum: float
  :param epsilon: small number to add to variances to ensure numerical stability
  :type epsilon: float
  
  References:
  
  [1] Sergey Ioffe and Christian Szegedy. Batch Normalization: Accelerating Deep
  Network Training by Reducing Internal Covariate Shift. In International
  Conference on Machine Learning, 2015. https://arxiv.org/abs/1502.03167
  
  [2] Laurent Dinh, Jascha Sohl-Dickstein, and Samy Bengio. Density Estimation
  using Real NVP. In International Conference on Learning Representations, 2017.
  https://arxiv.org/abs/1605.08803
  
  [3] George Papamakarios, Theo Pavlakou, and Iain Murray. Masked Autoregressive
  Flow for Density Estimation. In Neural Information Processing Systems, 2017.
  https://arxiv.org/abs/1705.07057
code: def constrained_gamma(self):
      return F.relu(self.gamma) + 1e-6
  
file_path: pyro/pyro/distributions/transforms/batchnorm.py
imports: import torch
  import torch.nn
  import torch.nn.functional
  from ..None import constraints
  from ..torch_transform import TransformModule
  from ..util import copy_docs_from
label_desc: Use image node_id 2 for calling the BatchNorm obj's underlying member method code with example usage: obj.constrained_gamma() and returns: unknown