import torch


def rejoin_props(datasets):
    """
    Rejoin properties from datasets into one dictionary of
    properties.
    Args:
        datasets (list): list of smaller datasets
    Returns:
        new_props (dict): combined properties
    """
    new_props = {}
    for dataset in datasets:
        for key, val in dataset.props.items():
            if key not in new_props:
                new_props[key] = val
                continue

            if type(val) is list:
                new_props[key] += val
            else:
                new_props[key] = torch.cat([
                    new_props[key], val], dim=0)

    return new_props