import torch


def get_parent_tensor(parent_sample_dict, continuous_parent_names):
    """

    Args:
        parent_sample_dict: contains dictionary of pyro.sample()s for all parents
        continuous_parent_names: parent name in order

    Returns: tensor with all the parent pyro.sample() values. This will get used to predict child value
        from train_network.

    """
    continuous_sample_list = []
    for parent_name in continuous_parent_names:
        try:
            continuous_sample_list.append(parent_sample_dict[parent_name])
        except:
            raise Exception("Something went wrong while get_parent_tensor")

    # converting 1-d tensor to 2-d
    output_tensor = torch.FloatTensor(continuous_sample_list).view(len(continuous_sample_list), 1)

    return output_tensor