import torch


def paramsDict2Tensor(params):
    """Concatenates all parameters in a ParameterDict to a single onedimensional tensor."""
    
    # awkward way to get the device of parameters in params
    if params:
        device = list(params.values())[0].device
        x = torch.tensor([], device = device)
    else:
        return None
    
    for key, val in params.items():
        x = torch.cat((x, val.flatten()))
    return x