class_docstr: UHiFiGAN generator module.
class_docstr_tok: ["UHiFiGAN","generator","module","."]
docstr: Calculate forward propagation.
  
  Args:
      c (Tensor): Input tensor (B, in_channels, T).
      f0 (Tensor): Input tensor (B, 1, T).
      excitation (Tensor): Input tensor (B, frame_len, T).
  
  Returns:
      Tensor: Output tensor (B, out_channels, T).
docstr_tok: ["Calculate","forward","propagation",".","Args",":","c","(","Tensor",")",":","Input","tensor","(","B",",","in_channels",",","T",")",".","f0","(","Tensor",")",":","Input","tensor","(","B",",","1",",","T",")",".","excitation","(","Tensor",")",":","Input","tensor","(","B",",","frame_len",",","T",")",".","Returns",":","Tensor",":","Output","tensor","(","B",",","out_channels",",","T",")","."]
code: def forward(
      self,
      c=None,
      f0=None,
      excitation=None,
      g: Optional[torch.Tensor] = None,
  ):
      """Calculate forward propagation.
  
      Args:
          c (Tensor): Input tensor (B, in_channels, T).
          f0 (Tensor): Input tensor (B, 1, T).
          excitation (Tensor): Input tensor (B, frame_len, T).
  
      Returns:
          Tensor: Output tensor (B, out_channels, T).
  
      """
      # logging.warn(f'c:{c.shape}')
      # logging.warn(f'f0:{f0.shape}')
      # logging.warn(f'excitation:{excitation.shape}')
  
      # logging.info(f'c:{c.shape}')
      # if f0 is not None:
      #     c = torch.cat( (c,f0), 1)
      # if excitation is not None:
      #     c = torch.cat( (c,excitation), 1)
      # if f0 is not None and excitation is not None:
      #     c = torch.cat( (c, f0, excitation) ,1)
      # elif f0 is not None:
      #     c = torch.cat( (c,f0), 1)
      # elif excitation is not None:
      #     c = torch.cat( (c,excitation), 1)
  
      residual_results = []
      if self.use_avocodo:
          outs = []
      hidden = self.input_conv(excitation)
  
      # TODO(yifeng): add global conv to hidden?
      if g is not None:
          c = c + self.global_conv(g)
  
      for i in range(len(self.downsamples)):
          cs = 0.0  # initialize
          for j in range(self.num_blocks):
              tc = self.downsamples_mrf[i * self.num_blocks + j](hidden)
              cs += tc
          hidden = cs / self.num_blocks
          hidden = self.downsamples[i](hidden)
          # print(f"hidden.shape{i}", hidden.shape)
          residual_results.append(hidden)
  
      # logging.warn(f'hidden:{hidden.shape}')
      residual_results.reverse()
      # logging.warn(f"residual_results:{ [r.shape for r in residual_results] }")
  
      hidden_mel = self.hidden_conv(c)
  
      for i in range(len(self.upsamples)):
          # logging.warn(f'bef {i}-th upsampe:{hidden_mel.shape}')
          # logging.warn(f'bef {i}-th upsampe:{residual_results[i].shape}')
          # print("hidden_mel.shape1", hidden_mel.shape)
          hidden_mel = torch.cat(
              (hidden_mel, residual_results[i]), dim=1
          )
          # logging.warn(f'aft {i}-th upsample :{hidden_mel.shape}')
          # print("hidden_mel.shape2", hidden_mel.shape)
          hidden_mel = self.upsamples[i](hidden_mel)
          # print("hidden_mel.shape3", hidden_mel.shape)
          # logging.warn(f'bef {i}-th MRF:{hidden_mel.shape}')
          # logging.warn(f'self.upsamples_mrf:{self.upsamples_mrf}')
          cs = 0.0  # initialize
          for j in range(self.num_blocks):
              tc = self.upsamples_mrf[i * self.num_blocks + j](
                  hidden_mel
              )
              # logging.info(f'{j}-th tc.shape:{tc.shape}')
              cs += tc
          hidden_mel = cs / self.num_blocks
          # logging.warn(f'aft {i}-th MRF:{hidden_mel.shape}')
          if self.use_avocodo:
              if i >= (self.num_upsamples - 3):
                  _c = F.leaky_relu(hidden_mel)
                  _c = self.output_conv[i](_c)
                  _c = torch.tanh(_c)
                  outs.append(_c)
              else:
                  hidden_mel = self.output_conv[i](hidden_mel)
  
      # logging.warn(f'bef output conv mel : {hidden_mel.shape}')
      if self.use_avocodo:
          return outs
      else:
          return self.output_conv(hidden_mel)
  
file_path: espnet/espnet2/gan_svs/uhifigan/uhifigan.py
imports: import logging
  from typing import List, Optional
  import numpy
  import torch
  import torch.nn.functional
label_desc: Use image node_id 2 for calling the UHiFiGANGenerator obj's underlying member method code with example usage: obj.forward(c, f0, excitation, g) and returns: outs, self