code: def label_collate(labels, device=None):
      """Collates the label inputs for the rnn-t prediction network.
      If `labels` is already in torch.Tensor form this is a no-op.
  
      Args:
          labels: A torch.Tensor List of label indexes or a torch.Tensor.
          device: Optional torch device to place the label on.
  
      Returns:
          A padded torch.Tensor of shape (batch, max_seq_len).
      """
  
      if isinstance(labels, torch.Tensor):
          return labels.type(torch.int64)
      if not isinstance(labels, (list, tuple)):
          raise ValueError(
              f"`labels` should be a list or tensor not {type(labels)}"
          )
  
      batch_size = len(labels)
      max_len = max(len(label) for label in labels)
  
      cat_labels = np.full(
          (batch_size, max_len), fill_value=0.0, dtype=np.int32
      )
      for e, l in enumerate(labels):
          cat_labels[e, : len(l)] = l
      labels = torch.tensor(
          cat_labels, dtype=torch.int64, device=device
      )
  
      return labels
  
imports: import math
  from typing import List, Optional, Tuple, Union
  import numpy
  import torch
  from nemo.utils import logging
label_desc: Use image node_id 4 for calling a global function with example usage: label_collate(labels, device) and returns: labels, labels