code: def pad_2d_float(
      batch: List[List[float]],
      seq_lens: List[int],
      pad_val: float = 0.0,
      max_len: int = -1,
  ) -> List[List[float]]:
      pad_to_length = max(seq_lens)
      if max_len > 0:
          pad_to_length = min(pad_to_length, max_len)
      for sentence in batch:
          padding = pad_to_length - len(sentence)
          if padding >= 0:
              for _ in range(padding):
                  sentence.append(pad_val)
          else:
              for _ in range(-padding):
                  sentence.pop()
      return batch
  
imports: from typing import List, NamedTuple, Optional, Tuple
  import torch
  from torch import Tensor
label_desc: Use image node_id 11 for calling a global function with example usage: pad_2d_float(batch, seq_lens, pad_val, max_len) and returns: batch