code: def all_states(n, big_endian=False):
      
      if n == 0:
          return
  
      for state in product((0, 1), repeat=n):
          if big_endian:
              yield state
          else:
              yield state[::-1]
docs: 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``.