from typing import List


def get_cost_vector(counts: dict) -> List[float]:
    """
    This function simply gives values that represent how far away from our desired goal we are. Said desired goal is that
    we get as close to 0 counts for the states |00> and |11>, and as close to 50% of the total counts for |01> and |10>
    each.

    :param counts: Dictionary containing the count of each state
    :return: List of ints that determine how far the count of each state is from the desired count for that state:
                -First element corresponds to |00>
                -Second element corresponds to |01>
                -Third element corresponds to |10>
                -Fourth element corresponds to |11>
    """
    # First we get the counts of each state. Try-except blocks are to avoid errors when the count is 0.
    try:
        a = counts['00']
    except KeyError:
        a = 0
    try:
        b = counts['01']
    except KeyError:
        b = 0
    try:
        c = counts['10']
    except KeyError:
        c = 0
    try:
        d = counts['11']
    except KeyError:
        d = 0

    # We then want the total number of shots to know what proportions we should expect
    totalShots = a + b + c + d

    # We return the absolute value of the difference of each state's observed and desired counts
    # Other systems to determine how far each state count is from the goal exist, but this one is simple and works well
    return [abs(a - 0), abs(b - totalShots / 2), abs(c - totalShots / 2), abs(d - 0)]