class_docstr: Residual Block with dilated convolution
  
  Arguments
  ---------
  n_mels:
      input mel channels of conv1x1 for conditional vocoding task
  residual_channels:
      channels of audio convolution
  dilation:
      dilation cycles of audio convolution
  uncond:
      conditional/unconditional generation
  
  Example
  -------
  >>> from speechbrain.lobes.models.DiffWave import ResidualBlock
  >>> res_block = ResidualBlock(n_mels=80, residual_channels=64, dilation=3)
  >>> noisy_audio = torch.randn(1, 1, 22050)
  >>> timestep_embedding = torch.rand(1, 512)
  >>> upsampled_mel = torch.rand(1, 80, 22050)
  >>> output = res_block(noisy_audio, timestep_embedding, upsampled_mel)
  >>> output[0].shape
  torch.Size([1, 64, 22050])
class_docstr_tok: ["Residual","Block","with","dilated","convolution","Arguments","--","--","--","--","-","n_mels",":","input","mel","channels","of","conv1x1","for","conditional","vocoding","task","residual_channels",":","channels","of","audio","convolution","dilation",":","dilation","cycles","of","audio","convolution","uncond",":","conditional\/unconditional","generation","Example","--","--","--","-",">",">",">","from","speechbrain.lobes.models.DiffWave","import","ResidualBlock",">",">",">","res_block","=","ResidualBlock","(","n_mels=80",",","residual_channels=64",",","dilation=3",")",">",">",">","noisy_audio","=","torch.randn","(","1",",","1",",","22050",")",">",">",">","timestep_embedding","=","torch.rand","(","1",",","512",")",">",">",">","upsampled_mel","=","torch.rand","(","1",",","80",",","22050",")",">",">",">","output","=","res_block","(","noisy_audio",",","timestep_embedding",",","upsampled_mel",")",">",">",">","output","[","0","]",".shape","torch.Size","(","[","1",",","64",",","22050","]",")"]
docstr: forward function of Residual Block
  
  Arguments
  ---------
  x: torch.Tensor
      input sample [bs, 1, time]
  diffusion_step: torch.Tensor
      the embedding of which step of diffusion to execute
  conditioner: torch.Tensor
      the condition used for conditional generation
  Returns
  -------
  residual output [bs, residual_channels, time]
  a skip of residual branch [bs, residual_channels, time]
docstr_tok: ["forward","function","of","Residual","Block","Arguments","--","--","--","--","-","x",":","torch.Tensor","input","sample","[","bs",",","1",",","time","]","diffusion_step",":","torch.Tensor","the","embedding","of","which","step","of","diffusion","to","execute","conditioner",":","torch.Tensor","the","condition","used","for","conditional","generation","Returns","--","--","--","-","residual","output","[","bs",",","residual_channels",",","time","]","a","skip","of","residual","branch","[","bs",",","residual_channels",",","time","]"]
code: def forward(self, x, diffusion_step, conditioner=None):
      """
      forward function of Residual Block
  
      Arguments
      ---------
      x: torch.Tensor
          input sample [bs, 1, time]
      diffusion_step: torch.Tensor
          the embedding of which step of diffusion to execute
      conditioner: torch.Tensor
          the condition used for conditional generation
      Returns
      -------
      residual output [bs, residual_channels, time]
      a skip of residual branch [bs, residual_channels, time]
      """
      assert (
          conditioner is None and self.conditioner_projection is None
      ) or (
          conditioner is not None
          and self.conditioner_projection is not None
      )
  
      diffusion_step = self.diffusion_projection(
          diffusion_step
      ).unsqueeze(-1)
      y = x + diffusion_step
      if (
          self.conditioner_projection is None
      ):  # using a unconditional model
          y = self.dilated_conv(y)
      else:
          conditioner = self.conditioner_projection(conditioner)
          # for inference make sure that they have the same length
          # conditioner = conditioner[:, :, y.shape[-1]]
          y = self.dilated_conv(y) + conditioner
  
      gate, filter = torch.chunk(y, 2, dim=1)
      y = torch.sigmoid(gate) * torch.tanh(filter)
  
      y = self.output_projection(y)
      residual, skip = torch.chunk(y, 2, dim=1)
      return (x + residual) / sqrt(2.0), skip
  
imports: import torch
  import torch.nn
  import torch.nn.functional
  from speechbrain.nnet.CNN import Conv1d
  from speechbrain.nnet import linear
  from speechbrain.nnet.diffusion import DenoisingDiffusion
  from math import sqrt
  from torchaudio import transforms
label_desc: Use image node_id 2 for calling the ResidualBlock obj's underlying member method code with example usage: obj.forward(x, diffusion_step, conditioner) and returns: unknown,  skip