import torch


def draw_random_learning_rates(args, learning_rates_to_sample, number_random_samples):
    """Draws the given number of random samples for the given learning rates with the distribution specified in args.method

    Args:
        args (OmegaConf): Hyperparameters. Contain information for the distribution where samples should be drawn from.
        learning_rates_to_sample (list of str): List containing all learning rates (and their order) for which random samples should be drawn.
        number_random_samples (int): Number of random samples that should be drawn.

    Returns:
        torch.Tensor: number_random_samples x len(learning_rates_to_sample) dimensional tensor where each row contains random samples for the learning rates specified in learning_rates_to_sample (in their ordering)
    """
    samples = []
    for val in learning_rates_to_sample:
        random_sample = torch.FloatTensor(
            number_random_samples,
            1
        ).uniform_(
            args.method.learning_rate_interval[val][0] + args.method.interval_epsilon[val][0],
            args.method.learning_rate_interval[val][1] - args.method.interval_epsilon[val][1]
        )
        samples.append(random_sample)
    return torch.cat(samples, dim=1)