import random


def get_fixed_embedding(QUBO, complete_embedding, random_state=42):
    """
    Given an input of a QUBO and an embedding, this function maps the variables from
    the qubo onto the embedding.

    Parameters
    ----------
    QUBO : dict
        dictionary where the keys are linear or quadratic terms, and the values are real numbers.
        Represents a Quadratic Unconstrained Binary Optimization problem.
    complete_embedding : dict
        all-to-all connectivity embedding for the given QUBO.
    random_state : integer, optional
        random seed parameter. The default is 42.

    Returns
    -------
    QUBO_embedding : dict
        remapped embedding for QUBO.

    """
    random.seed(random_state)

    linear_variables = []
    quadratic_variables = []
    for a in QUBO:
        if a[0] == a[1]:
            linear_variables.append(a[0])
        else:
            quadratic_variables.append(a)
    QUBO_embedding = {}
    complete_vars = list(complete_embedding.keys())
    random.shuffle(complete_vars)
    for i in range(len(linear_variables)):
        QUBO_embedding[linear_variables[i]] = complete_embedding[complete_vars[i]]
    return QUBO_embedding