  Quaternionic automorphic representations are one attempt to generalize to
other groups the special place holomorphic modular forms have among automorphic
representations of $\mathrm{GL}_2$. Here, we use "hyperendoscopy" techniques to
develop a general trace formula and understand them on an arbitrary group. Then
we specialize this general formula to study quaternionic automorphic
representations on the exceptional group $G_2$, eventually getting an analog of
the Eichler-Selberg trace formula for classical modular forms. We finally use
this together with some techniques of Chenevier, Renard, and Ta\"ibi to compute
dimensions of spaces of level-$1$ quaternionic representations. On the way, we
prove a Jacquet-Langlands-style result describing them in terms of classical
modular forms and automorphic representations on the compact-at-infinity form
$G_2^c$.
  The main technical difficulty is that the quaternionic discrete series that
quaternionic automorphic representations are defined in terms of do not satisfy
a condition of being "regular". A real representation theory argument shows
that regularity miraculously does not matter for specifically the case of
quaternionic discrete series.
  We hope that the techniques and shortcuts highlighted in this project are of
interest in other computations about discrete-at-infinity automorphic
representations on arbitrary reductive groups instead of just classical ones.
