code: def pad_sequence(
      seq: torch.Tensor, max_len: int, pad_token: int = 0
  ) -> torch.Tensor:
      """
      Params:
          - seq: integer token sequences of shape BxT
          - max_len: integer for max sequence length
          - pad_token: integer token for padding
      Returns:
          - padded sequence of shape B x max_len
      """
      batch = seq.size(0)
      curr_len = seq.size(1)
      if curr_len >= max_len:
          return seq
  
      padding = torch.zeros(
          batch, max_len - curr_len, dtype=seq.dtype, device=seq.device
      ).fill_(pad_token)
      return torch.cat([seq, padding], dim=1)
  
file_path: NeMo/nemo/collections/asr/parts/utils/slu_utils.py
imports: from dataclasses import dataclass
  from typing import List, Optional
  import torch
  from omegaconf import DictConfig
  from nemo.collections.asr.modules.transformer import BeamSearchSequenceGenerator, GreedySequenceGenerator, TopKSequenceGenerator
  from nemo.collections.common.tokenizers.tokenizer_spec import TokenizerSpec
  from nemo.core.classes.module import NeuralModule
label_desc: Use image node_id 2 for calling a global function with example usage: pad_sequence(seq, max_len, pad_token) and returns: torch, seq