code: def pad_first_dim(sequence, max_len, pad_value):
      """Pads the first dimension of the input `sequence` to `max_len`."""
      sequence_length = tf.shape(sequence)[0]
      padding_pattern = [
          [0, tf.maximum(0, max_len - sequence_length)],
      ]
  
      num_dim = len(tf.shape(sequence))
      if num_dim > 1:
          padding_pattern.extend([[0, 0]] * (num_dim - 1))
      return tf.pad(
          tensor=sequence,
          paddings=padding_pattern,
          constant_values=pad_value,
      )
  
imports: import functools
  from typing import Any, Dict, Optional, Sequence
  from absl import logging
  from dmvr import builders
  from dmvr import processors
  from dmvr import tokenizers
  import numpy
  from scenic.projects.mbt.datasets.dataset_utils import _decode_spectrogram
  from scenic.projects.mbt.datasets.dataset_utils import apply_specaugment
  import tensorflow
label_desc: Use image node_id 1 for calling a global function with example usage: pad_first_dim(sequence, max_len, pad_value) and returns: tf