code: def pad_single_with_feat_spec(
      ls: List[int],
      feat_spec: FeaturizationSpec,
      pad_idx: int,
      check=True,
  ):
      """Apply padding to sequence according to settings from FeaturizationSpec.
  
      Args:
          ls (List[int]): sequence to pad.
          feat_spec (FeaturizationSpec): metadata containing max sequence length and padding settings.
          pad_idx (int): element to use for padding.
          check (bool): True if padded length should be checked as under the max sequence length.
  
      Returns:
          Sequence with padding applied.
  
      """
      return pad_to_max_seq_length(
          ls=ls,
          max_seq_length=feat_spec.max_seq_length,
          pad_idx=pad_idx,
          pad_right=not feat_spec.pad_on_left,
          check=check,
      )
  
imports: import numpy
  from dataclasses import dataclass
  from typing import List, NamedTuple
  from jiant.tasks.core import FeaturizationSpec
  from jiant.tasks.utils import truncate_sequences, pad_to_max_seq_length
  from jiant.utils.python.datastructures import BiMap
label_desc: Use image node_id 9 for calling a global function with example usage: pad_single_with_feat_spec(ls, feat_spec, pad_idx, check) and returns: pad_to_max_seq_length