class_docstr: A BatchNorm layer used in several flows
class_docstr_tok: ["A","BatchNorm","layer","used","in","several","flows"]
code: def inverse(self, y):
      if self.training:
          if not hasattr(self, "batch_mean") or not hasattr(
              self, "batch_var"
          ):
              mean = torch.zeros(1).to(y.device)
              var = torch.ones(1).to(y.device)
  
          else:
              mean = self.batch_mean
              var = self.batch_var
  
      else:
          mean = self.running_mean
          var = self.running_var
  
      x = (y - self.beta) * (-self.log_gamma).exp() * (
          var + self.eps
      ).sqrt() + mean
  
      log_abs_det_jac = -self.log_gamma + 0.5 * (var + self.eps).log()
  
      output = ModelOutput(
          out=x,
          log_abs_det_jac=log_abs_det_jac.expand_as(x).sum(dim=-1),
      )
  
      return output
  
file_path: benchmark_VAE/src/pythae/models/normalizing_flows/layers.py
imports: import torch
  import torch.nn
  import torch.nn.functional
  from pythae.models.base.base_utils import ModelOutput
label_desc: Use image node_id 3 for calling the BatchNorm obj's underlying member method code with example usage: obj.inverse(y) and returns: output