docs: def validate_normalized_state(state: np.ndarray,
                                num_qubits: int,
                                dtype: Type[np.number] = np.complex64) -> None:
      """Validates that the given state is a valid wave function."""
      if state.size != 1 << num_qubits:
          raise ValueError(
              'State has incorrect size. Expected {} but was {}.'.format(
                  1 << num_qubits, state.size))
      if state.dtype != dtype:
          raise ValueError(
              'State has invalid dtype. Expected {} but was {}'.format(
                  dtype, state.dtype))
      norm = np.sum(np.abs(state) ** 2)
      if not np.isclose(norm, 1):
          raise ValueError('State is not normalized instead had norm %s' % norm)