class_docstr: Modified RealNVP Coupling Layers per the MAF paper
class_docstr_tok: ["Modified","RealNVP","Coupling","Layers","per","the","MAF","paper"]
code: def __init__(
      self,
      input_size,
      hidden_size,
      n_hidden,
      mask,
      cond_label_size=None,
  ):
      super().__init__()
  
      self.register_buffer("mask", mask)
  
      # scale function
      s_net = [
          nn.Linear(
              input_size
              + (cond_label_size if cond_label_size is not None else 0),
              hidden_size,
          )
      ]
      for _ in range(n_hidden):
          s_net += [nn.Tanh(), nn.Linear(hidden_size, hidden_size)]
      s_net += [nn.Tanh(), nn.Linear(hidden_size, input_size)]
      self.s_net = nn.Sequential(*s_net)
  
      # translation function
      self.t_net = copy.deepcopy(self.s_net)
      # replace Tanh with ReLU's per MAF paper
      for i in range(len(self.t_net)):
          if not isinstance(self.t_net[i], nn.Linear):
              self.t_net[i] = nn.ReLU()
  
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 1 to create a new LinearMaskedCoupling object from inherited base classes: nn with example: obj = LinearMaskedCoupling(input_size, hidden_size, n_hidden, mask, cond_label_size)