<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _check_kets(*ops, same_space=False, disjunct_space=False):
 """Check that all operands are Kets from the same Hilbert space."""

    if not all([(isinstance(o, State) and o.isket) for o in ops]):
        raise TypeError("All operands must be Kets")
    if same_space:
        if not len({o.space for o in ops if o is not ZeroKet}) == 1:
            raise UnequalSpaces(str(ops))
    if disjunct_space:
        spc = TrivialSpace
        for o in ops:
            if o.space & spc > TrivialSpace:
                raise OverlappingSpaces(str(ops))
            spc *= o.space