import torch


def stack_tensor_dict_list(tensor_dict_list):
    """ Stack tensors in a list of dictionaries. """
    keys = tensor_dict_list[0].keys()
    res = {}
    for key in keys:
        res[key] = torch.stack([d[key] for d in tensor_dict_list])
    return res