class_docstr: Adapted from WN() module in WaveGlow with modififcations to variable names
class_docstr_tok: ["Adapted","from","WN","(",")","module","in","WaveGlow","with","modififcations","to","variable","names"]
code: def __init__(
      self,
      n_in_channels,
      n_context_dim,
      n_layers,
      n_channels,
      kernel_size=5,
      affine_activation="softplus",
      use_partial_padding=True,
  ):
      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()
      start = torch.nn.Conv1d(
          n_in_channels + n_context_dim, n_channels, 1
      )
      start = torch.nn.utils.weight_norm(start, name="weight")
      self.start = start
      self.softplus = torch.nn.Softplus()
      self.affine_activation = affine_activation
      self.use_partial_padding = use_partial_padding
      # 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 = ConvNorm(
              n_channels,
              n_channels,
              kernel_size=kernel_size,
              dilation=dilation,
              padding=padding,
              use_partial_padding=use_partial_padding,
              use_weight_norm=True,
          )
          self.in_layers.append(in_layer)
          res_skip_layer = nn.Conv1d(n_channels, n_channels, 1)
          res_skip_layer = nn.utils.weight_norm(res_skip_layer)
          self.res_skip_layers.append(res_skip_layer)
  
imports: from typing import Optional, Tuple
  import numpy
  import torch
  from torch import Tensor, nn
  from torch.cuda import amp
  from torch.cuda.amp import autocast
  from torch.nn import functional
  from nemo.collections.tts.modules.submodules import ConvNorm, LinearNorm, MaskedInstanceNorm1d
  from nemo.collections.tts.parts.utils.helpers import get_mask_from_lengths, sort_tensor, unsort_tensor
  from nemo.collections.tts.parts.utils.splines import piecewise_linear_inverse_transform, piecewise_linear_transform, unbounded_piecewise_quadratic_transform
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_context_dim, n_layers, n_channels, kernel_size, affine_activation, use_partial_padding)