docstr: Applies a crossfade and unfolds into a 1d array.
  Args:
      y (ndarry)    : Batched sequences of audio samples
                      shape=(num_folds, target + 2 * overlap)
                      dtype=np.float64
      overlap (int) : Timesteps for both xfade and rnn warmup
  Return:
      (ndarry) : audio samples in a 1d array
                 shape=(total_len)
                 dtype=np.float64
  Details:
      y = [[seq1],
           [seq2],
           [seq3]]
      Apply a gain envelope at both ends of the sequences
      y = [[seq1_in, seq1_target, seq1_out],
           [seq2_in, seq2_target, seq2_out],
           [seq3_in, seq3_target, seq3_out]]
      Stagger and add up the groups of samples:
      [seq1_in, seq1_target, (seq1_out + seq2_in), seq2_target, ...]
docstr_tok: ["Applies","a","crossfade","and","unfolds","into","a","1d","array",".","Args",":","y","(","ndarry",")",":","Batched","sequences","of","audio","samples","shape=","(","num_folds",",","target","+","2","*","overlap",")","dtype=np.float64","overlap","(","int",")",":","Timesteps","for","both","xfade","and","rnn","warmup","Return",":","(","ndarry",")",":","audio","samples","in","a","1d","array","shape=","(","total_len",")","dtype=np.float64","Details",":","y","=","[","[","seq1","]",",","[","seq2","]",",","[","seq3","]","]","Apply","a","gain","envelope","at","both","ends","of","the","sequences","y","=","[","[","seq1_in",",","seq1_target",",","seq1_out","]",",","[","seq2_in",",","seq2_target",",","seq2_out","]",",","[","seq3_in",",","seq3_target",",","seq3_out","]","]","Stagger","and","add","up","the","groups","of","samples",":","[","seq1_in",",","seq1_target",",","(","seq1_out","+","seq2_in",")",",","seq2_target",",","...","]"]
code: def xfade_and_unfold(y, target, overlap):
      """Applies a crossfade and unfolds into a 1d array.
      Args:
          y (ndarry)    : Batched sequences of audio samples
                          shape=(num_folds, target + 2 * overlap)
                          dtype=np.float64
          overlap (int) : Timesteps for both xfade and rnn warmup
      Return:
          (ndarry) : audio samples in a 1d array
                     shape=(total_len)
                     dtype=np.float64
      Details:
          y = [[seq1],
               [seq2],
               [seq3]]
          Apply a gain envelope at both ends of the sequences
          y = [[seq1_in, seq1_target, seq1_out],
               [seq2_in, seq2_target, seq2_out],
               [seq3_in, seq3_target, seq3_out]]
          Stagger and add up the groups of samples:
          [seq1_in, seq1_target, (seq1_out + seq2_in), seq2_target, ...]
      """
  
      num_folds, length = y.shape
      target = length - 2 * overlap
      total_len = num_folds * (target + overlap) + overlap
  
      # Need some silence for the rnn warmup
      silence_len = overlap // 2
      fade_len = overlap - silence_len
      silence = np.zeros((silence_len), dtype=np.float64)
  
      # Equal power crossfade
      t = np.linspace(-1, 1, fade_len, dtype=np.float64)
      fade_in = np.sqrt(0.5 * (1 + t))
      fade_out = np.sqrt(0.5 * (1 - t))
  
      # Concat the silence to the fades
      fade_in = np.concatenate([silence, fade_in])
      fade_out = np.concatenate([fade_out, silence])
  
      # Apply the gain to the overlap samples
      y[:, :overlap] *= fade_in
      y[:, -overlap:] *= fade_out
  
      unfolded = np.zeros((total_len), dtype=np.float64)
  
      # Loop to add up all the samples
      for i in range(num_folds):
          start = i * (target + overlap)
          end = start + target + 2 * overlap
          unfolded[start:end] += y[i]
  
      return unfolded
  
imports: import sys
  import torch
  import torch.nn
  import numpy
  import torch.nn.functional
  import time
  from TTS.utils.audio import AudioProcessor
  from TTS.vocoder.utils.distribution import sample_from_gaussian, sample_from_discretized_mix_logistic
label_desc: Use image node_id 8 for calling the WaveRNN obj's underlying member method code with example usage: obj.xfade_and_unfold(y, target, overlap) and returns: unfolded