class_docstr: Style MelGAN generator module.
docstr: Initilize StyleMelGANGenerator module.
  
  Args:
      in_channels (int): Number of input noise channels.
      aux_channels (int): Number of auxiliary input channels.
      channels (int): Number of channels for conv layer.
      out_channels (int): Number of output channels.
      kernel_size (int): Kernel size of conv layers.
      dilation (int): Dilation factor for conv layers.
      bias (bool): Whether to add bias parameter in convolution layers.
      noise_upsample_scales (List[int]): List of noise upsampling scales.
      noise_upsample_activation (str): Activation function module name for noise
          upsampling.
      noise_upsample_activation_params (Dict[str, Any]): Hyperparameters for the
          above activation function.
      upsample_scales (List[int]): List of upsampling scales.
      upsample_mode (str): Upsampling mode in TADE layer.
      gated_function (str): Gated function used in TADEResBlock
          ("softmax" or "sigmoid").
      use_weight_norm (bool): Whether to use weight norm.
          If set to true, it will be applied to all of the conv layers.
docstr_tok: ["Initilize","StyleMelGANGenerator","module",".","Args",":","in_channels","(","int",")",":","Number","of","input","noise","channels",".","aux_channels","(","int",")",":","Number","of","auxiliary","input","channels",".","channels","(","int",")",":","Number","of","channels","for","conv","layer",".","out_channels","(","int",")",":","Number","of","output","channels",".","kernel_size","(","int",")",":","Kernel","size","of","conv","layers",".","dilation","(","int",")",":","Dilation","factor","for","conv","layers",".","bias","(","bool",")",":","Whether","to","add","bias","parameter","in","convolution","layers",".","noise_upsample_scales","(","List","[","int","]",")",":","List","of","noise","upsampling","scales",".","noise_upsample_activation","(","str",")",":","Activation","function","module","name","for","noise","upsampling",".","noise_upsample_activation_params","(","Dict","[","str",",","Any","]",")",":","Hyperparameters","for","the","above","activation","function",".","upsample_scales","(","List","[","int","]",")",":","List","of","upsampling","scales",".","upsample_mode","(","str",")",":","Upsampling","mode","in","TADE","layer",".","gated_function","(","str",")",":","Gated","function","used","in","TADEResBlock","(","``","softmax","''","or","``","sigmoid","''",")",".","use_weight_norm","(","bool",")",":","Whether","to","use","weight","norm",".","If","set","to","true",",","it","will","be","applied","to","all","of","the","conv","layers","."]
code: def __init__(
      self,
      in_channels: int = 128,
      aux_channels: int = 80,
      channels: int = 64,
      out_channels: int = 1,
      kernel_size: int = 9,
      dilation: int = 2,
      bias: bool = True,
      noise_upsample_scales: List[int] = [11, 2, 2, 2],
      noise_upsample_activation: str = "LeakyReLU",
      noise_upsample_activation_params: Dict[str, Any] = {
          "negative_slope": 0.2
      },
      upsample_scales: List[int] = [2, 2, 2, 2, 2, 2, 2, 2, 1],
      upsample_mode: str = "nearest",
      gated_function: str = "softmax",
      use_weight_norm: bool = True,
  ):
      """Initilize StyleMelGANGenerator module.
  
      Args:
          in_channels (int): Number of input noise channels.
          aux_channels (int): Number of auxiliary input channels.
          channels (int): Number of channels for conv layer.
          out_channels (int): Number of output channels.
          kernel_size (int): Kernel size of conv layers.
          dilation (int): Dilation factor for conv layers.
          bias (bool): Whether to add bias parameter in convolution layers.
          noise_upsample_scales (List[int]): List of noise upsampling scales.
          noise_upsample_activation (str): Activation function module name for noise
              upsampling.
          noise_upsample_activation_params (Dict[str, Any]): Hyperparameters for the
              above activation function.
          upsample_scales (List[int]): List of upsampling scales.
          upsample_mode (str): Upsampling mode in TADE layer.
          gated_function (str): Gated function used in TADEResBlock
              ("softmax" or "sigmoid").
          use_weight_norm (bool): Whether to use weight norm.
              If set to true, it will be applied to all of the conv layers.
  
      """
      super().__init__()
  
      self.in_channels = in_channels
  
      noise_upsample = []
      in_chs = in_channels
      for noise_upsample_scale in noise_upsample_scales:
          # NOTE(kan-bayashi): How should we design noise upsampling part?
          noise_upsample += [
              torch.nn.ConvTranspose1d(
                  in_chs,
                  channels,
                  noise_upsample_scale * 2,
                  stride=noise_upsample_scale,
                  padding=noise_upsample_scale // 2
                  + noise_upsample_scale % 2,
                  output_padding=noise_upsample_scale % 2,
                  bias=bias,
              )
          ]
          noise_upsample += [
              getattr(torch.nn, noise_upsample_activation)(
                  **noise_upsample_activation_params
              )
          ]
          in_chs = channels
      self.noise_upsample = torch.nn.Sequential(*noise_upsample)
      self.noise_upsample_factor = int(np.prod(noise_upsample_scales))
  
      self.blocks = torch.nn.ModuleList()
      aux_chs = aux_channels
      for upsample_scale in upsample_scales:
          self.blocks += [
              TADEResBlock(
                  in_channels=channels,
                  aux_channels=aux_chs,
                  kernel_size=kernel_size,
                  dilation=dilation,
                  bias=bias,
                  upsample_factor=upsample_scale,
                  upsample_mode=upsample_mode,
                  gated_function=gated_function,
              ),
          ]
          aux_chs = channels
      self.upsample_factor = int(
          np.prod(upsample_scales) * out_channels
      )
  
      self.output_conv = torch.nn.Sequential(
          torch.nn.Conv1d(
              channels,
              out_channels,
              kernel_size,
              1,
              bias=bias,
              padding=(kernel_size - 1) // 2,
          ),
          torch.nn.Tanh(),
      )
  
      # apply weight norm
      if use_weight_norm:
          self.apply_weight_norm()
  
      # reset parameters
      self.reset_parameters()
  
imports: import copy
  import logging
  import math
  from typing import Any, Dict, List, Optional
  import numpy
  import torch
  import torch.nn.functional
  from espnet2.gan_tts.melgan import MelGANDiscriminator
  from espnet2.gan_tts.melgan.pqmf import PQMF
  from espnet2.gan_tts.style_melgan.tade_res_block import TADEResBlock
label_desc: Use image node_id 1 to create a new StyleMelGANGenerator object from inherited base classes: torch.nn with example: obj = StyleMelGANGenerator(in_channels, aux_channels, channels, out_channels, kernel_size, dilation, bias, noise_upsample_scales, noise_upsample_activation, noise_upsample_activation_params, upsample_scales, upsample_mode, gated_function, use_weight_norm)