def matrix_from_basis_coefficients(
    expansion: value.LinearDict[str], basis: dict[str, np.ndarray]
) -> np.ndarray:
    """Computes linear combination of basis vectors with given coefficients."""
    some_element = next(iter(basis.values()))
    result = np.zeros_like(some_element, dtype=np.complex128)
    for name, coefficient in expansion.items():
        result += complex(coefficient) * basis[name]
    return result
Computes linear combination of basis vectors with given coefficients.
cirq-core/cirq/linalg/operator_spaces.py