Return the unitary of a pyQuil program.

    :param program: A program consisting only of :py:class:`Gate`.:
    :return: a unitary corresponding to the composition of the program's gates.

def program_unitary(program, n_qubits):
    """
    Return the unitary of a pyQuil program.

    :param program: A program consisting only of :py:class:`Gate`.:
    :return: a unitary corresponding to the composition of the program's gates.
    """
    umat = np.eye(2 ** n_qubits)
    for instruction in program:
        if isinstance(instruction, Gate):
            unitary = lifted_gate(gate=instruction, n_qubits=n_qubits)
            umat = unitary.dot(umat)
        else:
            raise ValueError("Can only compute program unitary for programs composed of `Gate`s")
    return umat