Let $N$ be a nonzero rational number. For every prime number $p$ with $v_p(N)=0$, let $a_p$ denote the index in $\mathbb Z/p\mathbb Z$ of the subgroup generated by $N$ modulo $p$. So we have $a_p=1$ if and only if $N$ is a primitive root mod $p$.

Is there an automorphic form which encodes the numbers $a_p$?

Let me explain: To give $N$ is the same thing as to give a group homomorphism $\mathbb Z \to \mathbb G_m$ over $\mathrm{spec}\mathbb Q$. Such a morphism is also the same as an extension $$0\to \mathbb Q(1) \to M \to \mathbb Q \to 0$$ of motives over $\mathrm{spec}\mathbb Q$. The motive $M$ is an example of a "mixed Tate motive", and also an example of a 1--motive. Its weights are $0$ and $-2$. The condition $v_p(N)=0$ means then that $M$ has good reduction at the prime $p$, i.e. extends to a 1--motive over the local ring at $p$. The number $a_p$ is then given by $$a_p = H^0(\mathbb F_p,M)$$ where we interpret $M = [\mathbb Z \to \mathbb G_m]$ as a complex concentrated in degrees $-1$ and $0$. With $M$ are associated "realisations", in particular $M$ comes with integral $\ell$--adic representations. So to restate the question:

Is there an automorphic form corresponding to $M$?

We could look at the L-function associated with the $\ell$--adic representation of $M$ to get a hint. The problem with this is that the L-function does not see the extension structure, it only depends on the semisimplification of the representation. This is clear because it is constructed by taking *traces* of Frobenius elements -- the L-function is in fact $\zeta(s)\zeta(s-1)$, independently of $N$.

I don't know if morally the association Motives $\to$ Automorphic forms which is classically conjectured for *pure* motives should extend to mixed motives... also, I don't know what a mixed automorphic form is. Maybe these are simply automorphic forms for nonreductive groups? There is a theory of "mixed modular forms" by Min Ho Lee, but I don't think this is what I am looking for.