def get_shape_from_hamiltonian(h_site, axis_1=None):
    """
        Constructs a chain shape tuple from an iterable of site local operators and an optional array-like ancilla_dims
    :param h_site: Iterable of quadratic site local operators (is exhausted after this function call). Is used
                   to determine the axis 0 dimensions of the chain (for the first leg on each site)
    :param axis_1: Optional iterable of dimensions for the second leg on each site of the chain (of the same size
                   as axis_0)
    :return: chain shape tuple
    """
    shape = []
    if axis_1 is None:
        for site in h_site:
            assert site.shape[0] == site.shape[1]
            shape.append((site.shape[0], ))
    else:
        for site, dim1 in zip(h_site, axis_1):
            assert site.shape[0] == site.shape[1]
            shape.append((site.shape[0], dim1))
    return tuple(shape)