code: def pad_tensor_dict(tensor_dict, max_len, mode="zero"):
      """Pad dictionary of tensors.
  
      Args:
          tensor_dict (dict[numpy.ndarray]): Tensors to be padded.
          max_len (int): Maximum length.
          mode (str): If 'last', pad with the last element, otherwise pad with 0.
  
      Returns:
          dict[numpy.ndarray]: Padded tensor.
  
      """
      keys = list(tensor_dict.keys())
      ret = dict()
      for k in keys:
          if isinstance(tensor_dict[k], dict):
              ret[k] = pad_tensor_dict(
                  tensor_dict[k], max_len, mode=mode
              )
          else:
              ret[k] = pad_tensor(tensor_dict[k], max_len, mode=mode)
  
      return ret
  
file_path: garage/src/garage/np/_functions.py
imports: import warnings
  import numpy
  import scipy.signal
label_desc: Use image node_id 9 for calling a global function with example usage: pad_tensor_dict(tensor_dict, max_len, mode) and returns: ret