class_docstr: Zero-pads model inputs and targets based on number of frames per step
  
  Arguments
  ---------
  n_frames_per_step: int
      the number of output frames per step
  
  Returns
  -------
  result: tuple
      a tuple of tensors to be used as inputs/targets
      (
          text_padded,
          input_lengths,
          mel_padded,
          gate_padded,
          output_lengths,
          len_x
      )
class_docstr_tok: ["Zero-pads","model","inputs","and","targets","based","on","number","of","frames","per","step","Arguments","--","--","--","--","-","n_frames_per_step",":","int","the","number","of","output","frames","per","step","Returns","--","--","--","-","result",":","tuple","a","tuple","of","tensors","to","be","used","as","inputs\/targets","(","text_padded",",","input_lengths",",","mel_padded",",","gate_padded",",","output_lengths",",","len_x",")"]
docstr: Collate's training batch from normalized text and mel-spectrogram
  Arguments
  ---------
  batch: list
      [text_normalized, mel_normalized]
docstr_tok: ["Collate","'s","training","batch","from","normalized","text","and","mel-spectrogram","Arguments","--","--","--","--","-","batch",":","list","[","text_normalized",",","mel_normalized","]"]
code: def __call__(self, batch):
      """Collate's training batch from normalized text and mel-spectrogram
      Arguments
      ---------
      batch: list
          [text_normalized, mel_normalized]
      """
  
      # TODO: Remove for loops and this dirty hack
      raw_batch = list(batch)
      for i in range(
          len(batch)
      ):  # the pipline return a dictionary wiht one elemnent
          batch[i] = batch[i]["mel_text_pair"]
  
      # Right zero-pad all one-hot text sequences to max input length
      input_lengths, ids_sorted_decreasing = torch.sort(
          torch.LongTensor([len(x[0]) for x in batch]),
          dim=0,
          descending=True,
      )
      max_input_len = input_lengths[0]
  
      text_padded = torch.LongTensor(len(batch), max_input_len)
      text_padded.zero_()
      for i in range(len(ids_sorted_decreasing)):
          text = batch[ids_sorted_decreasing[i]][0]
          text_padded[i, : text.size(0)] = text
  
      # Right zero-pad mel-spec
      num_mels = batch[0][1].size(0)
      max_target_len = max([x[1].size(1) for x in batch])
      if max_target_len % self.n_frames_per_step != 0:
          max_target_len += (
              self.n_frames_per_step
              - max_target_len % self.n_frames_per_step
          )
          assert max_target_len % self.n_frames_per_step == 0
  
      # include mel padded and gate padded
      mel_padded = torch.FloatTensor(
          len(batch), num_mels, max_target_len
      )
      mel_padded.zero_()
      gate_padded = torch.FloatTensor(len(batch), max_target_len)
      gate_padded.zero_()
      output_lengths = torch.LongTensor(len(batch))
      labels, wavs = [], []
      for i in range(len(ids_sorted_decreasing)):
          idx = ids_sorted_decreasing[i]
          mel = batch[idx][1]
          mel_padded[i, :, : mel.size(1)] = mel
          gate_padded[i, mel.size(1) - 1 :] = 1
          output_lengths[i] = mel.size(1)
          labels.append(raw_batch[idx]["label"])
          wavs.append(raw_batch[idx]["wav"])
  
      # count number of items - characters in text
      len_x = [x[2] for x in batch]
      len_x = torch.Tensor(len_x)
      return (
          text_padded,
          input_lengths,
          mel_padded,
          gate_padded,
          output_lengths,
          len_x,
          labels,
          wavs,
      )
  
imports: from math import sqrt
  from speechbrain.nnet.loss.guidedattn_loss import GuidedAttentionLoss
  from speechbrain.lobes.models.transformer.Transformer import get_mask_from_lengths
  import torch
  from torch import nn
  from torch.nn import functional
  from collections import namedtuple
label_desc: Use image node_id 2 for calling the TextMelCollate obj's underlying member method code with example usage: obj.__call__(batch) and returns: text_padded,  input_lengths,  mel_padded,  gate_padded,  output_lengths,  len_x,  labels,  wavs