class_docstr: This is the WaveNet like layer for the affine coupling.  The primary
  difference from WaveNet is the convolutions need not be causal.  There is
  also no dilation size reset.  The dilation only doubles on each layer
class_docstr_tok: ["This","is","the","WaveNet","like","layer","for","the","affine","coupling",".","The","primary","difference","from","WaveNet","is","the","convolutions","need","not","be","causal",".","There","is","also","no","dilation","size","reset",".","The","dilation","only","doubles","on","each","layer"]
code: def __init__(
      self,
      n_in_channels,
      n_mel_channels,
      n_layers,
      n_channels,
      kernel_size,
  ):
      super(WN, self).__init__()
      assert kernel_size % 2 == 1
      assert n_channels % 2 == 0
      self.n_layers = n_layers
      self.n_channels = n_channels
      self.in_layers = torch.nn.ModuleList()
      self.res_skip_layers = torch.nn.ModuleList()
      self.cond_layers = torch.nn.ModuleList()
  
      start = torch.nn.Conv1d(n_in_channels, n_channels, 1)
      start = torch.nn.utils.weight_norm(start, name="weight")
      self.start = start
  
      # Initializing last layer to 0 makes the affine coupling layers
      # do nothing at first.  This helps with training stability
      end = torch.nn.Conv1d(n_channels, 2 * n_in_channels, 1)
      end.weight.data.zero_()
      end.bias.data.zero_()
      self.end = end
  
      for i in range(n_layers):
          dilation = 2**i
          padding = int((kernel_size * dilation - dilation) / 2)
          in_layer = torch.nn.Conv1d(
              n_channels,
              2 * n_channels,
              kernel_size,
              dilation=dilation,
              padding=padding,
          )
          in_layer = torch.nn.utils.weight_norm(in_layer, name="weight")
          self.in_layers.append(in_layer)
  
          cond_layer = torch.nn.Conv1d(
              n_mel_channels, 2 * n_channels, 1
          )
          cond_layer = torch.nn.utils.weight_norm(
              cond_layer, name="weight"
          )
          self.cond_layers.append(cond_layer)
  
          # last one is not necessary
          if i < n_layers - 1:
              res_skip_channels = 2 * n_channels
          else:
              res_skip_channels = n_channels
          res_skip_layer = torch.nn.Conv1d(
              n_channels, res_skip_channels, 1
          )
          res_skip_layer = torch.nn.utils.weight_norm(
              res_skip_layer, name="weight"
          )
          self.res_skip_layers.append(res_skip_layer)
  
file_path: serve/examples/text_to_speech_synthesizer/waveglow_model.py
imports: import torch
  from torch.autograd import Variable
  import torch.nn.functional
label_desc: Use image node_id 1 to create a new WN object from inherited base classes: torch.nn with example: obj = WN(n_in_channels, n_mel_channels, n_layers, n_channels, kernel_size)