class_docstr: Conditional wavenet.
  
  Args:
      n_quantize (int): Number of quantization.
      n_aux (int): Number of aux feature dimension.
      n_resch (int): Number of filter channels for residual block.
      n_skipch (int): Number of filter channels for skip connection.
      dilation_depth (int): Number of dilation depth
          (e.g. if set 10, max dilation = 2^(10-1)).
      dilation_repeat (int): Number of dilation repeat.
      kernel_size (int): Filter size of dilated causal convolution.
      upsampling_factor (int): Upsampling factor.
class_docstr_tok: ["Conditional","wavenet",".","Args",":","n_quantize","(","int",")",":","Number","of","quantization",".","n_aux","(","int",")",":","Number","of","aux","feature","dimension",".","n_resch","(","int",")",":","Number","of","filter","channels","for","residual","block",".","n_skipch","(","int",")",":","Number","of","filter","channels","for","skip","connection",".","dilation_depth","(","int",")",":","Number","of","dilation","depth","(","e.g",".","if","set","10",",","max","dilation","=","2^","(","10-1",")",")",".","dilation_repeat","(","int",")",":","Number","of","dilation","repeat",".","kernel_size","(","int",")",":","Filter","size","of","dilated","causal","convolution",".","upsampling_factor","(","int",")",":","Upsampling","factor","."]
docstr: Generate a waveform with fast genration algorithm.
  
  This generation based on `Fast WaveNet Generation Algorithm`_.
  
  Args:
      x (LongTensor): Initial waveform tensor with the shape  (T,).
      h (Tensor): Auxiliary feature tensor with the shape  (n_samples + T, n_aux).
      n_samples (int): Number of samples to be generated.
      interval (int, optional): Log interval.
      mode (str, optional): "sampling" or "argmax".
  
  Return:
      ndarray: Generated quantized waveform (n_samples).
  
  .. _`Fast WaveNet Generation Algorithm`: https://arxiv.org/abs/1611.09482
docstr_tok: ["Generate","a","waveform","with","fast","genration","algorithm",".","This","generation","based","on","`","Fast","WaveNet","Generation","Algorithm","`","_",".","Args",":","x","(","LongTensor",")",":","Initial","waveform","tensor","with","the","shape","(","T",",",")",".","h","(","Tensor",")",":","Auxiliary","feature","tensor","with","the","shape","(","n_samples","+","T",",","n_aux",")",".","n_samples","(","int",")",":","Number","of","samples","to","be","generated",".","interval","(","int",",","optional",")",":","Log","interval",".","mode","(","str",",","optional",")",":","``","sampling","''","or","``","argmax","''",".","Return",":","ndarray",":","Generated","quantized","waveform","(","n_samples",")",".","..","_","`","Fast","WaveNet","Generation","Algorithm","`",":","https",":","\/\/arxiv.org\/abs\/1611.09482"]
code: def generate(self, x, h, n_samples, interval=None, mode="sampling"):
      """Generate a waveform with fast genration algorithm.
  
      This generation based on `Fast WaveNet Generation Algorithm`_.
  
      Args:
          x (LongTensor): Initial waveform tensor with the shape  (T,).
          h (Tensor): Auxiliary feature tensor with the shape  (n_samples + T, n_aux).
          n_samples (int): Number of samples to be generated.
          interval (int, optional): Log interval.
          mode (str, optional): "sampling" or "argmax".
  
      Return:
          ndarray: Generated quantized waveform (n_samples).
  
      .. _`Fast WaveNet Generation Algorithm`: https://arxiv.org/abs/1611.09482
  
      """
      # reshape inputs
      assert len(x.shape) == 1
      assert len(h.shape) == 2 and h.shape[1] == self.n_aux
      x = x.unsqueeze(0)
      h = h.transpose(0, 1).unsqueeze(0)
  
      # perform upsampling
      if self.upsampling_factor > 0:
          h = self.upsampling(h)
  
      # padding for shortage
      if n_samples > h.shape[2]:
          h = F.pad(h, (0, n_samples - h.shape[2]), "replicate")
  
      # padding if the length less than
      n_pad = self.receptive_field - x.size(1)
      if n_pad > 0:
          x = F.pad(x, (n_pad, 0), "constant", self.n_quantize // 2)
          h = F.pad(h, (n_pad, 0), "replicate")
  
      # prepare buffer
      output = self._preprocess(x)
      h_ = h[:, :, : x.size(1)]
      output_buffer = []
      buffer_size = []
      for i, d in enumerate(self.dilations):
          output, _ = self._residual_forward(
              output,
              h_,
              self.dil_sigmoid[i],
              self.dil_tanh[i],
              self.aux_1x1_sigmoid[i],
              self.aux_1x1_tanh[i],
              self.skip_1x1[i],
              self.res_1x1[i],
          )
          if d == 2 ** (self.dilation_depth - 1):
              buffer_size.append(self.kernel_size - 1)
          else:
              buffer_size.append(d * 2 * (self.kernel_size - 1))
          output_buffer.append(output[:, :, -buffer_size[i] - 1 : -1])
  
      # generate
      samples = x[0]
      start_time = time.time()
      for i in range(n_samples):
          output = samples[-self.kernel_size * 2 + 1 :].unsqueeze(0)
          output = self._preprocess(output)
          h_ = (
              h[:, :, samples.size(0) - 1]
              .contiguous()
              .view(1, self.n_aux, 1)
          )
          output_buffer_next = []
          skip_connections = []
          for j, d in enumerate(self.dilations):
              output, skip = self._generate_residual_forward(
                  output,
                  h_,
                  self.dil_sigmoid[j],
                  self.dil_tanh[j],
                  self.aux_1x1_sigmoid[j],
                  self.aux_1x1_tanh[j],
                  self.skip_1x1[j],
                  self.res_1x1[j],
              )
              output = torch.cat([output_buffer[j], output], dim=2)
              output_buffer_next.append(output[:, :, -buffer_size[j] :])
              skip_connections.append(skip)
  
          # update buffer
          output_buffer = output_buffer_next
  
          # get predicted sample
          output = sum(skip_connections)
          output = self._postprocess(output)[0]
          if mode == "sampling":
              posterior = F.softmax(output[-1], dim=0)
              dist = torch.distributions.Categorical(posterior)
              sample = dist.sample().unsqueeze(0)
          elif mode == "argmax":
              sample = output.argmax(-1)
          else:
              logging.error("mode should be sampling or argmax")
              sys.exit(1)
          samples = torch.cat([samples, sample], dim=0)
  
          # show progress
          if interval is not None and (i + 1) % interval == 0:
              elapsed_time_per_sample = (
                  time.time() - start_time
              ) / interval
              logging.info(
                  "%d/%d estimated time = %.3f sec (%.3f sec / sample)"
                  % (
                      i + 1,
                      n_samples,
                      (n_samples - i - 1) * elapsed_time_per_sample,
                      elapsed_time_per_sample,
                  )
              )
              start_time = time.time()
  
      return samples[-n_samples:].cpu().numpy()
  
imports: import logging
  import sys
  import time
  import numpy
  import torch
  import torch.nn.functional
  from torch import nn
label_desc: Use image node_id 3 for calling the WaveNet obj's underlying member method code with example usage: obj.generate(x, h, n_samples, interval, mode) and returns: samples