def tensor_product_basis(*bases):
    """
    Returns a TomographyBasis formed by the tensor
    product of two or more factor bases. Each basis element
    is the tensor product of basis elements from the underlying
    factors.
    """
    dim = np.prod([basis.data.shape[1] for basis in bases])
    tp_basis = np.zeros((dim**2, dim, dim), dtype=complex)

    for idx_factors, factors in enumerate(it.product(*[basis.data for basis in bases])):
        tp_basis[idx_factors, :, :] = reduce(np.kron, factors)

    return TomographyBasis(tp_basis,
        sum((
            factor.dims for factor in bases
        ), []),
        list(map(
        r"\otimes".join,
        it.product(*[
            basis.labels for basis in bases
        ])
    )))
def tensor_product_basis ( * bases ) : dim = np . prod ( [ basis . data . shape [ 1 ] for basis in bases ] ) tp_basis = np . zeros ( ( dim ** 2 , dim , dim ) , dtype = complex ) for idx_factors , factors in enumerate ( it . product ( * [ basis . data for basis in bases ] ) ) : tp_basis [ idx_factors , : , : ] = reduce ( np . kron , factors ) return TomographyBasis ( tp_basis , sum ( ( factor . dims for factor in bases ) , [ ] ) , list ( map ( r"\otimes" . join , it . product ( * [ basis . labels for basis in bases ] ) ) ) )
Returns a TomographyBasis formed by the tensor
    product of two or more factor bases. Each basis element
    is the tensor product of basis elements from the underlying
    factors.