def _create_standard_costfunction(name):
    """
    Creates the standard 'costfunctions' from an input string.

    This is used for calculating the "cost" of a circuit created by some compilation algorithms.

    Parameters
    ----------
    name : str
        Allowed values are:
            - '2QGC' : the cost of the circuit is the number of 2-qubit gates it contains.
            - 'depth' : the cost of the circuit is the depth of the circuit.
            - '2QGC:x:depth:y' : the cost of the circuit is x * the number of 2-qubit gates in the circuit +
                y * the depth of the circuit, where x and y are integers.

    Returns
    -------
    function
        A function that takes a circuit as the first argument, a QubitProcessorSpec as the second
        argument (or a "junk" input when a QubitProcessorSpec is not needed), and returns the cost
        of the circuit.
    """
    if name == '2QGC':
        def costfunction(circuit, junk):  # Junk input as no processorspec is needed here.
            return circuit.two_q_gate_count()
    elif name == 'depth':
        def costfunction(circuit, junk):  # Junk input as no processorspec is needed here.
            return circuit.depth

    # This allows for '2QGC:x:depth:y' strings
    elif name[:4] == '2QGC':

        s = name.split(":")
        try: twoQGCfactor = int(s[1])
        except: raise ValueError("This `costfunction` string is not a valid option!")
        assert(s[2] == 'depth'), "This `costfunction` string is not a valid option!"
        try: depthfactor = int(s[3])
        except: raise ValueError("This `costfunction` string is not a valid option!")

        def costfunction(circuit, junk):  # Junk input as no processorspec is needed here.
            return twoQGCfactor * circuit.two_q_gate_count() + depthfactor * circuit.depth

    else: raise ValueError("This `costfunction` string is not a valid option!")
    return costfunction