class_docstr: Parallel WaveGAN Generator module.
docstr: Initialize ParallelWaveGANGenerator module.
  
  Args:
      in_channels (int): Number of input channels.
      out_channels (int): Number of output channels.
      kernel_size (int): Kernel size of dilated convolution.
      layers (int): Number of residual block layers.
      stacks (int): Number of stacks i.e., dilation cycles.
      residual_channels (int): Number of channels in residual conv.
      gate_channels (int):  Number of channels in gated conv.
      skip_channels (int): Number of channels in skip conv.
      aux_channels (int): Number of channels for auxiliary feature conv.
      aux_context_window (int): Context window size for auxiliary feature.
      dropout_rate (float): Dropout rate. 0.0 means no dropout applied.
      bias (bool): Whether to use bias parameter in conv layer.
      use_weight_norm (bool): Whether to use weight norm.
          If set to true, it will be applied to all of the conv layers.
      upsample_conditional_features (bool): Whether to use upsampling network.
      upsample_net (str): Upsampling network architecture.
      upsample_params (Dict[str, Any]): Upsampling network parameters.
docstr_tok: ["Initialize","ParallelWaveGANGenerator","module",".","Args",":","in_channels","(","int",")",":","Number","of","input","channels",".","out_channels","(","int",")",":","Number","of","output","channels",".","kernel_size","(","int",")",":","Kernel","size","of","dilated","convolution",".","layers","(","int",")",":","Number","of","residual","block","layers",".","stacks","(","int",")",":","Number","of","stacks","i.e.",",","dilation","cycles",".","residual_channels","(","int",")",":","Number","of","channels","in","residual","conv",".","gate_channels","(","int",")",":","Number","of","channels","in","gated","conv",".","skip_channels","(","int",")",":","Number","of","channels","in","skip","conv",".","aux_channels","(","int",")",":","Number","of","channels","for","auxiliary","feature","conv",".","aux_context_window","(","int",")",":","Context","window","size","for","auxiliary","feature",".","dropout_rate","(","float",")",":","Dropout","rate",".","0.0","means","no","dropout","applied",".","bias","(","bool",")",":","Whether","to","use","bias","parameter","in","conv","layer",".","use_weight_norm","(","bool",")",":","Whether","to","use","weight","norm",".","If","set","to","true",",","it","will","be","applied","to","all","of","the","conv","layers",".","upsample_conditional_features","(","bool",")",":","Whether","to","use","upsampling","network",".","upsample_net","(","str",")",":","Upsampling","network","architecture",".","upsample_params","(","Dict","[","str",",","Any","]",")",":","Upsampling","network","parameters","."]
code: def __init__(
      self,
      in_channels: int = 1,
      out_channels: int = 1,
      kernel_size: int = 3,
      layers: int = 30,
      stacks: int = 3,
      residual_channels: int = 64,
      gate_channels: int = 128,
      skip_channels: int = 64,
      aux_channels: int = 80,
      aux_context_window: int = 2,
      dropout_rate: float = 0.0,
      bias: bool = True,
      use_weight_norm: bool = True,
      upsample_conditional_features: bool = True,
      upsample_net: str = "ConvInUpsampleNetwork",
      upsample_params: Dict[str, Any] = {
          "upsample_scales": [4, 4, 4, 4]
      },
  ):
      """Initialize ParallelWaveGANGenerator module.
  
      Args:
          in_channels (int): Number of input channels.
          out_channels (int): Number of output channels.
          kernel_size (int): Kernel size of dilated convolution.
          layers (int): Number of residual block layers.
          stacks (int): Number of stacks i.e., dilation cycles.
          residual_channels (int): Number of channels in residual conv.
          gate_channels (int):  Number of channels in gated conv.
          skip_channels (int): Number of channels in skip conv.
          aux_channels (int): Number of channels for auxiliary feature conv.
          aux_context_window (int): Context window size for auxiliary feature.
          dropout_rate (float): Dropout rate. 0.0 means no dropout applied.
          bias (bool): Whether to use bias parameter in conv layer.
          use_weight_norm (bool): Whether to use weight norm.
              If set to true, it will be applied to all of the conv layers.
          upsample_conditional_features (bool): Whether to use upsampling network.
          upsample_net (str): Upsampling network architecture.
          upsample_params (Dict[str, Any]): Upsampling network parameters.
  
      """
      super().__init__()
      self.in_channels = in_channels
      self.out_channels = out_channels
      self.aux_channels = aux_channels
      self.aux_context_window = aux_context_window
      self.layers = layers
      self.stacks = stacks
      self.kernel_size = kernel_size
  
      # check the number of layers and stacks
      assert layers % stacks == 0
      layers_per_stack = layers // stacks
  
      # define first convolution
      self.first_conv = Conv1d1x1(
          in_channels, residual_channels, bias=True
      )
  
      # define conv + upsampling network
      if upsample_conditional_features:
          if upsample_net == "ConvInUpsampleNetwork":
              upsample_params.update(
                  {
                      "aux_channels": aux_channels,
                      "aux_context_window": aux_context_window,
                  }
              )
          self.upsample_net = getattr(upsample, upsample_net)(
              **upsample_params
          )
          self.upsample_factor = int(
              np.prod(upsample_params["upsample_scales"])
          )
      else:
          self.upsample_net = None
          self.upsample_factor = out_channels
  
      # define residual blocks
      self.conv_layers = torch.nn.ModuleList()
      for layer in range(layers):
          dilation = 2 ** (layer % layers_per_stack)
          conv = ResidualBlock(
              kernel_size=kernel_size,
              residual_channels=residual_channels,
              gate_channels=gate_channels,
              skip_channels=skip_channels,
              aux_channels=aux_channels,
              dilation=dilation,
              dropout_rate=dropout_rate,
              bias=bias,
              scale_residual=True,
          )
          self.conv_layers += [conv]
  
      # define output layers
      self.last_conv_layers = torch.nn.ModuleList(
          [
              torch.nn.ReLU(),
              Conv1d1x1(skip_channels, skip_channels, bias=True),
              torch.nn.ReLU(),
              Conv1d1x1(skip_channels, out_channels, bias=True),
          ]
      )
  
      # apply weight norm
      if use_weight_norm:
          self.apply_weight_norm()
  
      # NOTE(kan-bayashi): register pre hook function for the compatibility with
      #   parallel_wavegan repo
      self._register_load_state_dict_pre_hook(
          self._load_state_dict_pre_hook
      )
  
imports: import logging
  import math
  from typing import Any, Dict, Optional
  import numpy
  import torch
  from espnet2.gan_tts.parallel_wavegan import upsample
  from espnet2.gan_tts.wavenet.residual_block import Conv1d, Conv1d1x1, ResidualBlock
label_desc: Use image node_id 1 to create a new ParallelWaveGANGenerator object from inherited base classes: torch.nn with example: obj = ParallelWaveGANGenerator(in_channels, out_channels, kernel_size, layers, stacks, residual_channels, gate_channels, skip_channels, aux_channels, aux_context_window, dropout_rate, bias, use_weight_norm, upsample_conditional_features, upsample_net, upsample_params)