class_docstr: MelGAN discriminator module.
docstr: Initilize MelGANDiscriminator module.
  
  Args:
      in_channels (int): Number of input channels.
      out_channels (int): Number of output channels.
      kernel_sizes (List[int]): List of two kernel sizes. The prod will be used
          for the first conv layer, and the first and the second kernel sizes
          will be used for the last two layers. For example if kernel_sizes =
          [5, 3], the first layer kernel size will be 5 * 3 = 15, the last two
          layers' kernel size will be 5 and 3, respectively.
      channels (int): Initial number of channels for conv layer.
      max_downsample_channels (int): Maximum number of channels for downsampling
          layers.
      bias (bool): Whether to add bias parameter in convolution layers.
      downsample_scales (List[int]): List of downsampling scales.
      nonlinear_activation (str): Activation function module name.
      nonlinear_activation_params (Dict[str, Any]): Hyperparameters for activation
          function.
      pad (str): Padding function module name before dilated convolution layer.
      pad_params (Dict[str, Any]): Hyperparameters for padding function.
docstr_tok: ["Initilize","MelGANDiscriminator","module",".","Args",":","in_channels","(","int",")",":","Number","of","input","channels",".","out_channels","(","int",")",":","Number","of","output","channels",".","kernel_sizes","(","List","[","int","]",")",":","List","of","two","kernel","sizes",".","The","prod","will","be","used","for","the","first","conv","layer",",","and","the","first","and","the","second","kernel","sizes","will","be","used","for","the","last","two","layers",".","For","example","if","kernel_sizes","=","[","5",",","3","]",",","the","first","layer","kernel","size","will","be","5","*","3","=","15",",","the","last","two","layers","'","kernel","size","will","be","5","and","3",",","respectively",".","channels","(","int",")",":","Initial","number","of","channels","for","conv","layer",".","max_downsample_channels","(","int",")",":","Maximum","number","of","channels","for","downsampling","layers",".","bias","(","bool",")",":","Whether","to","add","bias","parameter","in","convolution","layers",".","downsample_scales","(","List","[","int","]",")",":","List","of","downsampling","scales",".","nonlinear_activation","(","str",")",":","Activation","function","module","name",".","nonlinear_activation_params","(","Dict","[","str",",","Any","]",")",":","Hyperparameters","for","activation","function",".","pad","(","str",")",":","Padding","function","module","name","before","dilated","convolution","layer",".","pad_params","(","Dict","[","str",",","Any","]",")",":","Hyperparameters","for","padding","function","."]
code: def __init__(
      self,
      in_channels: int = 1,
      out_channels: int = 1,
      kernel_sizes: List[int] = [5, 3],
      channels: int = 16,
      max_downsample_channels: int = 1024,
      bias: bool = True,
      downsample_scales: List[int] = [4, 4, 4, 4],
      nonlinear_activation: str = "LeakyReLU",
      nonlinear_activation_params: Dict[str, Any] = {
          "negative_slope": 0.2
      },
      pad: str = "ReflectionPad1d",
      pad_params: Dict[str, Any] = {},
  ):
      """Initilize MelGANDiscriminator module.
  
      Args:
          in_channels (int): Number of input channels.
          out_channels (int): Number of output channels.
          kernel_sizes (List[int]): List of two kernel sizes. The prod will be used
              for the first conv layer, and the first and the second kernel sizes
              will be used for the last two layers. For example if kernel_sizes =
              [5, 3], the first layer kernel size will be 5 * 3 = 15, the last two
              layers' kernel size will be 5 and 3, respectively.
          channels (int): Initial number of channels for conv layer.
          max_downsample_channels (int): Maximum number of channels for downsampling
              layers.
          bias (bool): Whether to add bias parameter in convolution layers.
          downsample_scales (List[int]): List of downsampling scales.
          nonlinear_activation (str): Activation function module name.
          nonlinear_activation_params (Dict[str, Any]): Hyperparameters for activation
              function.
          pad (str): Padding function module name before dilated convolution layer.
          pad_params (Dict[str, Any]): Hyperparameters for padding function.
  
      """
      super().__init__()
      self.layers = torch.nn.ModuleList()
  
      # check kernel size is valid
      assert len(kernel_sizes) == 2
      assert kernel_sizes[0] % 2 == 1
      assert kernel_sizes[1] % 2 == 1
  
      # add first layer
      self.layers += [
          torch.nn.Sequential(
              getattr(torch.nn, pad)(
                  (np.prod(kernel_sizes) - 1) // 2, **pad_params
              ),
              torch.nn.Conv1d(
                  in_channels,
                  channels,
                  np.prod(kernel_sizes),
                  bias=bias,
              ),
              getattr(torch.nn, nonlinear_activation)(
                  **nonlinear_activation_params
              ),
          )
      ]
  
      # add downsample layers
      in_chs = channels
      for downsample_scale in downsample_scales:
          out_chs = min(
              in_chs * downsample_scale, max_downsample_channels
          )
          self.layers += [
              torch.nn.Sequential(
                  torch.nn.Conv1d(
                      in_chs,
                      out_chs,
                      kernel_size=downsample_scale * 10 + 1,
                      stride=downsample_scale,
                      padding=downsample_scale * 5,
                      groups=in_chs // 4,
                      bias=bias,
                  ),
                  getattr(torch.nn, nonlinear_activation)(
                      **nonlinear_activation_params
                  ),
              )
          ]
          in_chs = out_chs
  
      # add final layers
      out_chs = min(in_chs * 2, max_downsample_channels)
      self.layers += [
          torch.nn.Sequential(
              torch.nn.Conv1d(
                  in_chs,
                  out_chs,
                  kernel_sizes[0],
                  padding=(kernel_sizes[0] - 1) // 2,
                  bias=bias,
              ),
              getattr(torch.nn, nonlinear_activation)(
                  **nonlinear_activation_params
              ),
          )
      ]
      self.layers += [
          torch.nn.Conv1d(
              out_chs,
              out_channels,
              kernel_sizes[1],
              padding=(kernel_sizes[1] - 1) // 2,
              bias=bias,
          ),
      ]
  
imports: import logging
  from typing import Any, Dict, List
  import numpy
  import torch
  from espnet2.gan_tts.melgan.residual_stack import ResidualStack
label_desc: Use image node_id 1 to create a new MelGANDiscriminator object from inherited base classes: torch.nn with example: obj = MelGANDiscriminator(in_channels, out_channels, kernel_sizes, channels, max_downsample_channels, bias, downsample_scales, nonlinear_activation, nonlinear_activation_params, pad, pad_params)