class_docstr: SEANet decoder.
  
  Args:
      channels (int): Audio channels.
      dimension (int): Intermediate representation dimension.
      n_filters (int): Base width for the model.
      n_residual_layers (int): nb of residual layers.
      ratios (Sequence[int]): kernel size and stride ratios.
      activation (str): Activation function.
      activation_params (dict): Parameters to provide to the activation function.
      final_activation (str): Final activation function after all convolutions.
      final_activation_params (dict): Parameters to provide to the activation function.
      norm (str): Normalization method.
      norm_params (dict): Parameters to provide to the underlying normalization used along with the convolution.
      kernel_size (int): Kernel size for the initial convolution.
      last_kernel_size (int): Kernel size for the initial convolution.
      residual_kernel_size (int): Kernel size for the residual layers.
      dilation_base (int): How much to increase the dilation with each layer.
      causal (bool): Whether to use fully causal convolution.
      pad_mode (str): Padding mode for the convolutions.
      true_skip (bool): Whether to use true skip connection or a simple.
          (streamable) convolution as the skip connection in the residual network blocks.
      compress (int): Reduced dimensionality in residual branches (from Demucs v3).
      lstm (int): Number of LSTM layers at the end of the encoder.
      disable_norm_outer_blocks (int): Number of blocks for which we don't apply norm.
          For the decoder, it corresponds to the N last blocks.
      trim_right_ratio (float): Ratio for trimming at the right of the transposed convolution under the causal setup.
          If equal to 1.0, it means that all the trimming is done at the right.
class_docstr_tok: ["SEANet","decoder",".","Args",":","channels","(","int",")",":","Audio","channels",".","dimension","(","int",")",":","Intermediate","representation","dimension",".","n_filters","(","int",")",":","Base","width","for","the","model",".","n_residual_layers","(","int",")",":","nb","of","residual","layers",".","ratios","(","Sequence","[","int","]",")",":","kernel","size","and","stride","ratios",".","activation","(","str",")",":","Activation","function",".","activation_params","(","dict",")",":","Parameters","to","provide","to","the","activation","function",".","final_activation","(","str",")",":","Final","activation","function","after","all","convolutions",".","final_activation_params","(","dict",")",":","Parameters","to","provide","to","the","activation","function",".","norm","(","str",")",":","Normalization","method",".","norm_params","(","dict",")",":","Parameters","to","provide","to","the","underlying","normalization","used","along","with","the","convolution",".","kernel_size","(","int",")",":","Kernel","size","for","the","initial","convolution",".","last_kernel_size","(","int",")",":","Kernel","size","for","the","initial","convolution",".","residual_kernel_size","(","int",")",":","Kernel","size","for","the","residual","layers",".","dilation_base","(","int",")",":","How","much","to","increase","the","dilation","with","each","layer",".","causal","(","bool",")",":","Whether","to","use","fully","causal","convolution",".","pad_mode","(","str",")",":","Padding","mode","for","the","convolutions",".","true_skip","(","bool",")",":","Whether","to","use","true","skip","connection","or","a","simple",".","(","streamable",")","convolution","as","the","skip","connection","in","the","residual","network","blocks",".","compress","(","int",")",":","Reduced","dimensionality","in","residual","branches","(","from","Demucs","v3",")",".","lstm","(","int",")",":","Number","of","LSTM","layers","at","the","end","of","the","encoder",".","disable_norm_outer_blocks","(","int",")",":","Number","of","blocks","for","which","we","do","n't","apply","norm",".","For","the","decoder",",","it","corresponds","to","the","N","last","blocks",".","trim_right_ratio","(","float",")",":","Ratio","for","trimming","at","the","right","of","the","transposed","convolution","under","the","causal","setup",".","If","equal","to","1.0",",","it","means","that","all","the","trimming","is","done","at","the","right","."]
code: def __init__(
      self,
      channels: int = 1,
      dimension: int = 128,
      n_filters: int = 32,
      n_residual_layers: int = 3,
      ratios: tp.List[int] = [8, 5, 4, 2],
      activation: str = "ELU",
      activation_params: dict = {"alpha": 1.0},
      final_activation: tp.Optional[str] = None,
      final_activation_params: tp.Optional[dict] = None,
      norm: str = "none",
      norm_params: tp.Dict[str, tp.Any] = {},
      kernel_size: int = 7,
      last_kernel_size: int = 7,
      residual_kernel_size: int = 3,
      dilation_base: int = 2,
      causal: bool = False,
      pad_mode: str = "reflect",
      true_skip: bool = True,
      compress: int = 2,
      lstm: int = 0,
      disable_norm_outer_blocks: int = 0,
      trim_right_ratio: float = 1.0,
  ):
      super().__init__()
      self.dimension = dimension
      self.channels = channels
      self.n_filters = n_filters
      self.ratios = ratios
      del ratios
      self.n_residual_layers = n_residual_layers
      self.hop_length = np.prod(self.ratios)
      self.n_blocks = (
          len(self.ratios) + 2
      )  # first and last conv + residual blocks
      self.disable_norm_outer_blocks = disable_norm_outer_blocks
      assert (
          self.disable_norm_outer_blocks >= 0
          and self.disable_norm_outer_blocks <= self.n_blocks
      ), (
          "Number of blocks for which to disable norm is invalid."
          "It should be lower or equal to the actual number of blocks in the network and greater or equal to 0."
      )
  
      act = getattr(nn, activation)
      mult = int(2 ** len(self.ratios))
      model: tp.List[nn.Module] = [
          StreamableConv1d(
              dimension,
              mult * n_filters,
              kernel_size,
              norm="none"
              if self.disable_norm_outer_blocks == self.n_blocks
              else norm,
              norm_kwargs=norm_params,
              causal=causal,
              pad_mode=pad_mode,
          )
      ]
  
      if lstm:
          model += [StreamableLSTM(mult * n_filters, num_layers=lstm)]
  
      # Upsample to raw audio scale
      for i, ratio in enumerate(self.ratios):
          block_norm = (
              "none"
              if self.disable_norm_outer_blocks
              >= self.n_blocks - (i + 1)
              else norm
          )
          # Add upsampling layers
          model += [
              act(**activation_params),
              StreamableConvTranspose1d(
                  mult * n_filters,
                  mult * n_filters // 2,
                  kernel_size=ratio * 2,
                  stride=ratio,
                  norm=block_norm,
                  norm_kwargs=norm_params,
                  causal=causal,
                  trim_right_ratio=trim_right_ratio,
              ),
          ]
          # Add residual layers
          for j in range(n_residual_layers):
              model += [
                  SEANetResnetBlock(
                      mult * n_filters // 2,
                      kernel_sizes=[residual_kernel_size, 1],
                      dilations=[dilation_base**j, 1],
                      activation=activation,
                      activation_params=activation_params,
                      norm=block_norm,
                      norm_params=norm_params,
                      causal=causal,
                      pad_mode=pad_mode,
                      compress=compress,
                      true_skip=true_skip,
                  )
              ]
  
          mult //= 2
  
      # Add final layers
      model += [
          act(**activation_params),
          StreamableConv1d(
              n_filters,
              channels,
              last_kernel_size,
              norm="none"
              if self.disable_norm_outer_blocks >= 1
              else norm,
              norm_kwargs=norm_params,
              causal=causal,
              pad_mode=pad_mode,
          ),
      ]
      # Add optional final activation to decoder (eg. tanh)
      if final_activation is not None:
          final_act = getattr(nn, final_activation)
          final_activation_params = final_activation_params or {}
          model += [final_act(**final_activation_params)]
      self.model = nn.Sequential(*model)
  
file_path: audiocraft/audiocraft/modules/seanet.py
imports: import typing
  import numpy
  import torch.nn
  from .conv import StreamableConv1d, StreamableConvTranspose1d
  from .lstm import StreamableLSTM
label_desc: Use image node_id 1 to create a new SEANetDecoder object from inherited base classes: nn with example: obj = SEANetDecoder(channels, dimension, n_filters, n_residual_layers, ratios, activation, activation_params, final_activation, final_activation_params, norm, norm_params, kernel_size, last_kernel_size, residual_kernel_size, dilation_base, causal, pad_mode, true_skip, compress, lstm, disable_norm_outer_blocks, trim_right_ratio)