<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def all_states(n, big_endian=False):
 """Return all binary states for a system. Args: n (int):
 The number of elements in the system. big_endian (bool):
 Whether to return the states in big-endian order instead of little-endian order. Yields: tuple[int]: The next state of an ``n``-element system, in little-endian order unless ``big_endian`` is ``True``. """

    if n == 0:
        return

    for state in product((0, 1), repeat=n):
        if big_endian:
            yield state
        else:
            yield state[::-1]