class_docstr: HiFiGAN period discriminator module.
docstr: Initialize HiFiGANPeriodDiscriminator module.
  
  Args:
      in_channels (int): Number of input channels.
      out_channels (int): Number of output channels.
      period (int): Period.
      kernel_sizes (list): Kernel sizes of initial conv layers and the final conv
          layer.
      channels (int): Number of initial channels.
      downsample_scales (List[int]): List of downsampling scales.
      max_downsample_channels (int): Number of maximum downsampling channels.
      use_additional_convs (bool): Whether to use additional conv layers in
          residual blocks.
      bias (bool): Whether to add bias parameter in convolution layers.
      nonlinear_activation (str): Activation function module name.
      nonlinear_activation_params (Dict[str, Any]): Hyperparameters for activation
          function.
      use_weight_norm (bool): Whether to use weight norm.
          If set to true, it will be applied to all of the conv layers.
      use_spectral_norm (bool): Whether to use spectral norm.
          If set to true, it will be applied to all of the conv layers.
docstr_tok: ["Initialize","HiFiGANPeriodDiscriminator","module",".","Args",":","in_channels","(","int",")",":","Number","of","input","channels",".","out_channels","(","int",")",":","Number","of","output","channels",".","period","(","int",")",":","Period",".","kernel_sizes","(","list",")",":","Kernel","sizes","of","initial","conv","layers","and","the","final","conv","layer",".","channels","(","int",")",":","Number","of","initial","channels",".","downsample_scales","(","List","[","int","]",")",":","List","of","downsampling","scales",".","max_downsample_channels","(","int",")",":","Number","of","maximum","downsampling","channels",".","use_additional_convs","(","bool",")",":","Whether","to","use","additional","conv","layers","in","residual","blocks",".","bias","(","bool",")",":","Whether","to","add","bias","parameter","in","convolution","layers",".","nonlinear_activation","(","str",")",":","Activation","function","module","name",".","nonlinear_activation_params","(","Dict","[","str",",","Any","]",")",":","Hyperparameters","for","activation","function",".","use_weight_norm","(","bool",")",":","Whether","to","use","weight","norm",".","If","set","to","true",",","it","will","be","applied","to","all","of","the","conv","layers",".","use_spectral_norm","(","bool",")",":","Whether","to","use","spectral","norm",".","If","set","to","true",",","it","will","be","applied","to","all","of","the","conv","layers","."]
code: def __init__(
      self,
      in_channels: int = 1,
      out_channels: int = 1,
      period: int = 3,
      kernel_sizes: List[int] = [5, 3],
      channels: int = 32,
      downsample_scales: List[int] = [3, 3, 3, 3, 1],
      max_downsample_channels: int = 1024,
      bias: bool = True,
      nonlinear_activation: str = "LeakyReLU",
      nonlinear_activation_params: Dict[str, Any] = {
          "negative_slope": 0.1
      },
      use_weight_norm: bool = True,
      use_spectral_norm: bool = False,
  ):
      """Initialize HiFiGANPeriodDiscriminator module.
  
      Args:
          in_channels (int): Number of input channels.
          out_channels (int): Number of output channels.
          period (int): Period.
          kernel_sizes (list): Kernel sizes of initial conv layers and the final conv
              layer.
          channels (int): Number of initial channels.
          downsample_scales (List[int]): List of downsampling scales.
          max_downsample_channels (int): Number of maximum downsampling channels.
          use_additional_convs (bool): Whether to use additional conv layers in
              residual blocks.
          bias (bool): Whether to add bias parameter in convolution layers.
          nonlinear_activation (str): Activation function module name.
          nonlinear_activation_params (Dict[str, Any]): Hyperparameters for activation
              function.
          use_weight_norm (bool): Whether to use weight norm.
              If set to true, it will be applied to all of the conv layers.
          use_spectral_norm (bool): Whether to use spectral norm.
              If set to true, it will be applied to all of the conv layers.
  
      """
      super().__init__()
      assert len(kernel_sizes) == 2
      assert kernel_sizes[0] % 2 == 1, "Kernel size must be odd number."
      assert kernel_sizes[1] % 2 == 1, "Kernel size must be odd number."
  
      self.period = period
      self.convs = torch.nn.ModuleList()
      in_chs = in_channels
      out_chs = channels
      for downsample_scale in downsample_scales:
          self.convs += [
              torch.nn.Sequential(
                  torch.nn.Conv2d(
                      in_chs,
                      out_chs,
                      (kernel_sizes[0], 1),
                      (downsample_scale, 1),
                      padding=((kernel_sizes[0] - 1) // 2, 0),
                  ),
                  getattr(torch.nn, nonlinear_activation)(
                      **nonlinear_activation_params
                  ),
              )
          ]
          in_chs = out_chs
          # NOTE(kan-bayashi): Use downsample_scale + 1?
          out_chs = min(out_chs * 4, max_downsample_channels)
      self.output_conv = torch.nn.Conv2d(
          out_chs,
          out_channels,
          (kernel_sizes[1] - 1, 1),
          1,
          padding=((kernel_sizes[1] - 1) // 2, 0),
      )
  
      if use_weight_norm and use_spectral_norm:
          raise ValueError(
              "Either use use_weight_norm or use_spectral_norm."
          )
  
      # apply weight norm
      if use_weight_norm:
          self.apply_weight_norm()
  
      # apply spectral norm
      if use_spectral_norm:
          self.apply_spectral_norm()
  
imports: import copy
  import logging
  from typing import Any, Dict, List, Optional
  import numpy
  import torch
  import torch.nn.functional
  from espnet2.gan_tts.hifigan.residual_block import ResidualBlock
label_desc: Use image node_id 1 to create a new HiFiGANPeriodDiscriminator object from inherited base classes: torch.nn with example: obj = HiFiGANPeriodDiscriminator(in_channels, out_channels, period, kernel_sizes, channels, downsample_scales, max_downsample_channels, bias, nonlinear_activation, nonlinear_activation_params, use_weight_norm, use_spectral_norm)