class_docstr: Zero-pads model inputs and targets based on number of frames per step
  Arguments
  ---------
  speaker_embeddings_pickle : str
      Path to the file containing speaker embeddings
  n_frames_per_step: int
      The number of output frames per step
  Returns
  -------
  result: tuple
      a tuple inputs/targets
      (
          text_padded,
          input_lengths,
          mel_padded,
          gate_padded,
          output_lengths,
          len_x,
          labels,
          wavs,
          spk_embs,
          spk_ids
      )
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, spk_embs_list, spk_ids = [], [], [], []
      with open(
          self.speaker_embeddings_pickle, "rb"
      ) as speaker_embeddings_file:
          speaker_embeddings = pickle.load(speaker_embeddings_file)
  
      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"])
  
          spk_emb = speaker_embeddings[raw_batch[idx]["uttid"]]
          spk_embs_list.append(spk_emb)
  
          spk_ids.append(raw_batch[idx]["uttid"].split("_")[0])
  
      spk_embs = torch.stack(spk_embs_list)
  
      # 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,
          spk_embs,
          spk_ids,
      )
  
imports: from math import sqrt
  from speechbrain.nnet.loss.guidedattn_loss import GuidedAttentionLoss
  import torch
  from torch import nn
  from torch.nn import functional
  from collections import namedtuple
  import pickle
  from speechbrain.lobes.models.Tacotron2 import LinearNorm, Postnet, Encoder, Decoder, get_mask_from_lengths
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,  spk_embs,  spk_ids