class_docstr: WaveNet with global conditioning.
class_docstr_tok: ["WaveNet","with","global","conditioning","."]
docstr: Initialize WaveNet 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.
      base_dilation (int): Base dilation factor.
      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 local conditioning feature.
      global_channels (int): Number of channels for global conditioning 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.
      use_first_conv (bool): Whether to use the first conv layers.
      use_last_conv (bool): Whether to use the last conv layers.
      scale_residual (bool): Whether to scale the residual outputs.
      scale_skip_connect (bool): Whether to scale the skip connection outputs.
docstr_tok: ["Initialize","WaveNet","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",".","base_dilation","(","int",")",":","Base","dilation","factor",".","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","local","conditioning","feature",".","global_channels","(","int",")",":","Number","of","channels","for","global","conditioning","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",".","use_first_conv","(","bool",")",":","Whether","to","use","the","first","conv","layers",".","use_last_conv","(","bool",")",":","Whether","to","use","the","last","conv","layers",".","scale_residual","(","bool",")",":","Whether","to","scale","the","residual","outputs",".","scale_skip_connect","(","bool",")",":","Whether","to","scale","the","skip","connection","outputs","."]
code: def __init__(
      self,
      in_channels: int = 1,
      out_channels: int = 1,
      kernel_size: int = 3,
      layers: int = 30,
      stacks: int = 3,
      base_dilation: int = 2,
      residual_channels: int = 64,
      aux_channels: int = -1,
      gate_channels: int = 128,
      skip_channels: int = 64,
      global_channels: int = -1,
      dropout_rate: float = 0.0,
      bias: bool = True,
      use_weight_norm: bool = True,
      use_first_conv: bool = False,
      use_last_conv: bool = False,
      scale_residual: bool = False,
      scale_skip_connect: bool = False,
  ):
      """Initialize WaveNet 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.
          base_dilation (int): Base dilation factor.
          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 local conditioning feature.
          global_channels (int): Number of channels for global conditioning 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.
          use_first_conv (bool): Whether to use the first conv layers.
          use_last_conv (bool): Whether to use the last conv layers.
          scale_residual (bool): Whether to scale the residual outputs.
          scale_skip_connect (bool): Whether to scale the skip connection outputs.
  
      """
      super().__init__()
      self.layers = layers
      self.stacks = stacks
      self.kernel_size = kernel_size
      self.base_dilation = base_dilation
      self.use_first_conv = use_first_conv
      self.use_last_conv = use_last_conv
      self.scale_skip_connect = scale_skip_connect
  
      # check the number of layers and stacks
      assert layers % stacks == 0
      layers_per_stack = layers // stacks
  
      # define first convolution
      if self.use_first_conv:
          self.first_conv = Conv1d1x1(
              in_channels, residual_channels, bias=True
          )
  
      # define residual blocks
      self.conv_layers = torch.nn.ModuleList()
      for layer in range(layers):
          dilation = base_dilation ** (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,
              global_channels=global_channels,
              dilation=dilation,
              dropout_rate=dropout_rate,
              bias=bias,
              scale_residual=scale_residual,
          )
          self.conv_layers += [conv]
  
      # define output layers
      if self.use_last_conv:
          self.last_conv = torch.nn.Sequential(
              torch.nn.ReLU(inplace=True),
              Conv1d1x1(skip_channels, skip_channels, bias=True),
              torch.nn.ReLU(inplace=True),
              Conv1d1x1(skip_channels, out_channels, bias=True),
          )
  
      # apply weight norm
      if use_weight_norm:
          self.apply_weight_norm()
  
file_path: espnet/espnet2/gan_tts/wavenet/wavenet.py
imports: import logging
  import math
  from typing import Optional
  import torch
  from espnet2.gan_tts.wavenet.residual_block import Conv1d1x1, ResidualBlock
label_desc: Use image node_id 1 to create a new WaveNet object from inherited base classes: torch.nn with example: obj = WaveNet(in_channels, out_channels, kernel_size, layers, stacks, base_dilation, residual_channels, aux_channels, gate_channels, skip_channels, global_channels, dropout_rate, bias, use_weight_norm, use_first_conv, use_last_conv, scale_residual, scale_skip_connect)