class_docstr: Stochastic duration predictor module.
  
  This is a module of stochastic duration predictor described in `Conditional
  Variational Autoencoder with Adversarial Learning for End-to-End Text-to-Speech`_.
  
  .. _`Conditional Variational Autoencoder with Adversarial Learning for End-to-End
      Text-to-Speech`: https://arxiv.org/abs/2006.04558
docstr: Initialize StochasticDurationPredictor module.
  
  Args:
      channels (int): Number of channels.
      kernel_size (int): Kernel size.
      dropout_rate (float): Dropout rate.
      flows (int): Number of flows.
      dds_conv_layers (int): Number of conv layers in DDS conv.
      global_channels (int): Number of global conditioning channels.
code: def __init__(
      self,
      channels: int = 192,
      kernel_size: int = 3,
      dropout_rate: float = 0.5,
      flows: int = 4,
      dds_conv_layers: int = 3,
      global_channels: int = -1,
  ):
      """Initialize StochasticDurationPredictor module.
  
      Args:
          channels (int): Number of channels.
          kernel_size (int): Kernel size.
          dropout_rate (float): Dropout rate.
          flows (int): Number of flows.
          dds_conv_layers (int): Number of conv layers in DDS conv.
          global_channels (int): Number of global conditioning channels.
  
      """
      super().__init__()
  
      self.pre = torch.nn.Conv1d(channels, channels, 1)
      self.dds = DilatedDepthSeparableConv(
          channels,
          kernel_size,
          layers=dds_conv_layers,
          dropout_rate=dropout_rate,
      )
      self.proj = torch.nn.Conv1d(channels, channels, 1)
  
      self.log_flow = LogFlow()
      self.flows = torch.nn.ModuleList()
      self.flows += [ElementwiseAffineFlow(2)]
      for i in range(flows):
          self.flows += [
              ConvFlow(
                  2,
                  channels,
                  kernel_size,
                  layers=dds_conv_layers,
              )
          ]
          self.flows += [FlipFlow()]
  
      self.post_pre = torch.nn.Conv1d(1, channels, 1)
      self.post_dds = DilatedDepthSeparableConv(
          channels,
          kernel_size,
          layers=dds_conv_layers,
          dropout_rate=dropout_rate,
      )
      self.post_proj = torch.nn.Conv1d(channels, channels, 1)
      self.post_flows = torch.nn.ModuleList()
      self.post_flows += [ElementwiseAffineFlow(2)]
      for i in range(flows):
          self.post_flows += [
              ConvFlow(
                  2,
                  channels,
                  kernel_size,
                  layers=dds_conv_layers,
              )
          ]
          self.post_flows += [FlipFlow()]
  
      if global_channels > 0:
          self.global_conv = torch.nn.Conv1d(
              global_channels, channels, 1
          )
  
file_path: espnet/espnet2/gan_tts/vits/duration_predictor.py
imports: import math
  from typing import Optional
  import torch
  import torch.nn.functional
  from espnet2.gan_tts.vits.flow import ConvFlow, DilatedDepthSeparableConv, ElementwiseAffineFlow, FlipFlow, LogFlow
label_desc: Use image node_id 1 to create a new StochasticDurationPredictor object from inherited base classes: torch.nn with example: obj = StochasticDurationPredictor(channels, kernel_size, dropout_rate, flows, dds_conv_layers, global_channels)