code: def _speech_collate_fn(batch, pad_id):
      """collate batch of audio sig, audio len, tokens, tokens len
      Args:
          batch (Optional[FloatTensor], Optional[LongTensor], LongTensor,
                 LongTensor):  A tuple of tuples of signal, signal lengths,
                 encoded tokens, and encoded tokens length.  This collate func
                 assumes the signals are 1d torch tensors (i.e. mono audio).
      """
      _, audio_lengths, _, tokens_lengths = zip(*batch)
      max_audio_len = 0
      has_audio = audio_lengths[0] is not None
      if has_audio:
          max_audio_len = max(audio_lengths).item()
      max_tokens_len = max(tokens_lengths).item()
  
      audio_signal, tokens = [], []
      for sig, sig_len, tokens_i, tokens_i_len in batch:
          if has_audio:
              sig_len = sig_len.item()
              if sig_len < max_audio_len:
                  pad = (0, max_audio_len - sig_len)
                  sig = torch.nn.functional.pad(sig, pad)
              audio_signal.append(sig)
          tokens_i_len = tokens_i_len.item()
          if tokens_i_len < max_tokens_len:
              pad = (0, max_tokens_len - tokens_i_len)
              tokens_i = torch.nn.functional.pad(
                  tokens_i, pad, value=pad_id
              )
          tokens.append(tokens_i)
  
      if has_audio:
          audio_signal = torch.stack(audio_signal)
          audio_lengths = torch.stack(audio_lengths)
      else:
          audio_signal, audio_lengths = None, None
      tokens = torch.stack(tokens)
      tokens_lengths = torch.stack(tokens_lengths)
  
      return audio_signal, audio_lengths, tokens, tokens_lengths
  
imports: import io
  import os
  from typing import Dict, List, Optional, Union
  import torch
  import webdataset
  from nemo.collections.asr.data.audio_to_text import cache_datastore_manifests, expand_sharded_filepaths
  from nemo.collections.asr.parts.preprocessing.features import WaveformFeaturizer
  from nemo.collections.asr.parts.preprocessing.segment import available_formats
  from nemo.collections.common.parts.preprocessing import collections
  from nemo.core.classes import Dataset, IterableDataset
  from nemo.core.neural_types import AudioSignal, LabelsType, LengthsType, NeuralType, RegressionValuesType
  from nemo.utils import logging
label_desc: Use image node_id 4 for calling a global function with example usage: _speech_collate_fn(batch, pad_id) and returns: audio_signal,  audio_lengths,  tokens,  tokens_lengths