docstr: Fold the tensor with overlap for quick batched inference.
      Overlap will be used for crossfading in xfade_and_unfold()
  Args:
      x (tensor)    : Upsampled conditioning features.
                      shape=(1, timesteps, features)
      target (int)  : Target timesteps for each index of batch
      overlap (int) : Timesteps for both xfade and rnn warmup
  Return:
      (tensor) : shape=(num_folds, target + 2 * overlap, features)
  Details:
      x = [[h1, h2, ... hn]]
      Where each h is a vector of conditioning features
      Eg: target=2, overlap=1 with x.size(1)=10
      folded = [[h1, h2, h3, h4],
                [h4, h5, h6, h7],
                [h7, h8, h9, h10]]
docstr_tok: ["Fold","the","tensor","with","overlap","for","quick","batched","inference",".","Overlap","will","be","used","for","crossfading","in","xfade_and_unfold","(",")","Args",":","x","(","tensor",")",":","Upsampled","conditioning","features",".","shape=","(","1",",","timesteps",",","features",")","target","(","int",")",":","Target","timesteps","for","each","index","of","batch","overlap","(","int",")",":","Timesteps","for","both","xfade","and","rnn","warmup","Return",":","(","tensor",")",":","shape=","(","num_folds",",","target","+","2","*","overlap",",","features",")","Details",":","x","=","[","[","h1",",","h2",",","...","hn","]","]","Where","each","h","is","a","vector","of","conditioning","features","Eg",":","target=2",",","overlap=1","with","x.size","(","1",")","=10","folded","=","[","[","h1",",","h2",",","h3",",","h4","]",",","[","h4",",","h5",",","h6",",","h7","]",",","[","h7",",","h8",",","h9",",","h10","]","]"]
code: def fold_with_overlap(self, x, target, overlap):
      """Fold the tensor with overlap for quick batched inference.
          Overlap will be used for crossfading in xfade_and_unfold()
      Args:
          x (tensor)    : Upsampled conditioning features.
                          shape=(1, timesteps, features)
          target (int)  : Target timesteps for each index of batch
          overlap (int) : Timesteps for both xfade and rnn warmup
      Return:
          (tensor) : shape=(num_folds, target + 2 * overlap, features)
      Details:
          x = [[h1, h2, ... hn]]
          Where each h is a vector of conditioning features
          Eg: target=2, overlap=1 with x.size(1)=10
          folded = [[h1, h2, h3, h4],
                    [h4, h5, h6, h7],
                    [h7, h8, h9, h10]]
      """
  
      _, total_len, features = x.size()
  
      # Calculate variables needed
      num_folds = (total_len - overlap) // (target + overlap)
      extended_len = num_folds * (overlap + target) + overlap
      remaining = total_len - extended_len
  
      # Pad if some time steps poking out
      if remaining != 0:
          num_folds += 1
          padding = target + 2 * overlap - remaining
          x = self.pad_tensor(x, padding, side="after")
  
      folded = torch.zeros(
          num_folds, target + 2 * overlap, features
      ).to(x.device)
  
      # Get the values for the folded tensor
      for i in range(num_folds):
          start = i * (target + overlap)
          end = start + target + 2 * overlap
          folded[i] = x[:, start:end, :]
  
      return folded
  
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 5 for calling the WaveRNN obj's underlying member method code with example usage: obj.fold_with_overlap(x, target, overlap) and returns: folded