import torch


def rand_mat_list_like_parameters(problem, V):
    """Create list of random matrix with same trailing dimensions as parameters."""
    return [
        torch.rand(V, *p.shape, device=problem.device)
        for p in problem.model.parameters()
    ]