class_docstr: Modified RealNVP Coupling Layers per the MAF paper
class_docstr_tok: ["Modified","RealNVP","Coupling","Layers","per","the","MAF","paper"]
code: def forward(self, x, y=None):
      # apply mask
      mx = x * self.mask
  
      # run through model
      s = self.s_net(mx if y is None else torch.cat([y, mx], dim=-1))
      t = self.t_net(
          mx if y is None else torch.cat([y, mx], dim=-1)
      ) * (1 - self.mask)
  
      # cf RealNVP eq 8 where u corresponds to x (here we're modeling u)
      log_s = torch.tanh(s) * (1 - self.mask)
      u = x * torch.exp(log_s) + t
      # u = (x - t) * torch.exp(log_s)
      # u = mx + (1 - self.mask) * (x - t) * torch.exp(-s)
  
      # log det du/dx; cf RealNVP 8 and 6; note, sum over input_size done at model log_prob
      # log_abs_det_jacobian = -(1 - self.mask) * s
      # log_abs_det_jacobian = -log_s #.sum(-1, keepdim=True)
      log_abs_det_jacobian = log_s
  
      return u, log_abs_det_jacobian
  
imports: import copy
  import math
  import torch
  import torch.nn
  import torch.nn.functional
  from torch.distributions import Normal
label_desc: Use image node_id 2 for calling the LinearMaskedCoupling obj's underlying member method code with example usage: obj.forward(x, y) and returns: u,  log_abs_det_jacobian